You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.4 KiB

FROM nginx:1.25.1
WORKDIR /var/www/
# 安裝 PHP 和相關擴展
RUN groupadd --system --gid 1000 www \
&& useradd --system --gid www --no-create-home --home /nonexistent --comment "www user" --shell /bin/false --uid 1000 www \
&& ln -snf /usr/share/zoneinfo/Asia/Taipei /etc/localtime \
&& echo "Asia/Taipei" > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata \
&& apt-get update && apt-get install -y cron vim lsb-release apt-transport-https ca-certificates wget \
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list \
&& apt-get update \
&& apt-get install -y php8.0 php8.0-fpm php8.0-mysql php8.0-xml php8.0-gd php8.0-curl
RUN mkdir -p /var/www/ && chown -R www:www /var/www
# 複製 Nginx 配置文件
COPY nginx-php/nginx.conf /etc/nginx/nginx.conf
COPY nginx-php/default.conf /etc/nginx/conf.d/default.conf
# 複製 PHP-FPM 配置文件
COPY nginx-php/www.conf /etc/php/8.0/fpm/pool.d/www.conf
COPY --chown=www:www app /var/www/
COPY nginx-php/cronjob /etc/cron.d/uding-cron
RUN chmod 0644 /etc/cron.d/uding-cron && crontab /etc/cron.d/uding-cron
# 將 PHP-FPM 服務啟動
CMD service cron start && service php8.0-fpm start && nginx -g 'daemon off;'