Ubuntu 20.04 linphone-sdk Docker Image >>> build linphone-desktop and flexisip

Nginx(Alpine)コンテナでクローンデーモン起動

certbotによる認証更新をスケジュール管理するため、デフォルトのジョブNginxにクローンデーモンcrondによるジョブを追加します。

Dockerfile

nginx-alpine

FROM nginx:alpine

# Set working directory
WORKDIR /var/www/html

RUN apk add --no-cache bash nano tzdata certbot-nginx \
    && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \
    && echo "Asia/Tokyo" > /etc/timezone \
    && apk del tzdata
COPY nginx_default.conf /etc/nginx/conf.d/default.conf
COPY nginx_crond /etc/periodic/monthly
COPY nginx-crond.sh /
RUN chmod a+x /nginx-crond.sh
CMD ["/nginx-crond.sh"]

以下シェルスクリプトをクロンジョブのマンスリーディレクトリにコピー。
nginx-crond

#!/bin/sh
certbot renew
nginx -s reload

コンテナのマルチサービスを実行するスクリプト作成

nginx-crond.sh

#!/bin/bash

# turn on bash's job control
set -m

# Start the primary process and put it in the background
nginx -g 'daemon off;' &

# Start the helper process
crond

# the my_helper_process might need to know how to wait on the
# primary process to start before it does its work and returns

# now we bring the primary process back into the foreground
# and leave it there
fg %1