Gravλ₯Ό μ€ννκΈ° μν΄ μ체 Docker μ΄λ―Έμ§λ₯Ό μ€μ νμ§λ§ μ μ μλ λ¬Έμ κ° νλ μμ΅λλ€. μΉ UIμμ Cronμ μ¬μ©ν μ μλ€κ³ νμλμ§λ§ μμ§ μ λλ‘ μλνλ κ² κ°μ΅λλ€. λ΄κ° λ§ν μμλ κ²μμ μ’μ.
μ΄κ²μ λ΄κ° μμ νλ €λ κ²½κ³ μ
λλ€.
nginx μ¬μ©μλ‘ crontabμ μ€ννκ³ μλλ° μ μλνλ κ² κ°μ΅λλ€.
CLIλ₯Ό μ¬μ©νμ¬ nginx
μ μ¬λ°λ₯Έ crontabμ΄ μλμ§ νμΈν μ μμ΅λλ€.
κ·Έλ¦¬κ³ μ°¨μ΄κ° μλμ§ νμΈνκΈ° μν΄ λ£¨νΈ μ¬μ©μμκ²λ μΆκ°νμ΅λλ€.
... κ·Έλ¬λ μΉ UIμλ μ¬μ ν λμΌν κ²½κ³ κ° νμλ©λλ€.
CLIλ λν λ°±μ
μ΄ μ€νλκ³ μμμ 보μ¬μ€λλ€.
μ΄ κ²½κ³ λ₯Ό κ³ μΉ μ μλμ§ νμΈνκΈ° μν΄ λ¬΄μμ λ ν μ μλμ§ μ λͺ¨λ₯΄κ² μ΅λλ€.
λ΄ Dockerfile:
FROM nginx:stable-alpine
LABEL maintainer="William Miceli <[email protected]>"
USER root
ARG GRAV_VERSION
# Install Dependencies Needed For Grav, With Optional Modules To Help With Performance
RUN apk update && apk add --no-cache \
dcron \
php7 \
php7-curl \
php7-dom \
php7-fpm \
php7-gd \
php7-json \
php7-mbstring \
php7-openssl \
php7-pecl-apcu \
php7-pecl-yaml \
php7-session \
php7-simplexml \
php7-xml \
php7-zip
# Configure NGINX For Grav
ADD https://raw.githubusercontent.com/getgrav/grav/c381bc83040e00c9a8ebe91ac3bda5fe0c217197/webserver-configs/nginx.conf /etc/nginx/conf.d/default.conf
RUN sed -i 's/root \/home\/USER\/www\/html/root \/var\/www/g' /etc/nginx/conf.d/default.conf \
&& sed -i 's/fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock;/fastcgi_pass unix:\/var\/run\/php-fpm.sock;/g' /etc/nginx/conf.d/default.conf \
&& sed -i 's/#listen 80;/listen 80;/g' /etc/nginx/conf.d/default.conf \
&& sed -i '23cuser = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '24cgroup = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '47clisten.owner = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '48clisten.group = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '49clisten.mode = 0660' /etc/php7/php-fpm.d/www.conf \
&& sed -i 's/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g' /etc/php7/php-fpm.d/www.conf
# Setup Cron
RUN (crontab -u nginx -l; echo "* * * * * cd /var/www;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -u nginx -
# Prepare Grav Files
RUN mkdir -p /var/www /usr/src/grav/user \
&& apk add --no-cache ca-certificates \
&& apk add --no-cache --virtual .install-dependencies unzip wget \
&& wget -P /var/www https://github.com/getgrav/grav/releases/download/${GRAV_VERSION}/grav-admin-v${GRAV_VERSION}.zip \
&& unzip -q /var/www/grav-admin-v${GRAV_VERSION}.zip -d /var/www \
&& rm /var/www/grav-admin-v${GRAV_VERSION}.zip \
&& mv -v /var/www/grav-admin/* /var/www \
&& rm -rfv /var/www/grav-admin \
&& apk del .install-dependencies \
&& chown -R nginx:nginx /var/www \
&& mv -v /var/www/user/* /usr/src/grav/user
COPY /entrypoint.sh /
EXPOSE 80
CMD ["/bin/sh", "/entrypoint.sh"]
λμμ£Όμ μ κ°μ¬ν©λλ€!!
λν λ΄κ° μμ μ°¨λ¦° μμ μ μ μ°¨μ΄κ°μλ κ² κ°μ΅λλ€.
CLIλ crontabμΌλ‘ λ€μκ³Ό κ°μ΄ λ§ν©λλ€.
(crontab -l; echo "* * * * * cd /var/www;/usr/bin/php7 bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
μΉ UIλ λ€μκ³Ό κ°μ΄ λ§ν©λλ€.
(crontab -l; echo "* * * * * cd /var/www;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
(νλλ /usr/bin/php7
, λ€λ₯Έ νλλ /usr/bin/php
)
κ·Έκ² λκ° μ€μν μ§ λͺ¨λ₯΄κ² μ§λ§ μΈκΈν μκ°μ λλ€.
κ°μ₯ λ¨Όμ νμΈν΄μΌ ν κ²μ ν°λ―Έλμ μμ λμ λΉκ΅νμ¬ 'μΉμλ²'κ° μ€νλλ μ¬μ©μμ
λλ€. μ¬μ©μκ° λ€λ₯Έ κ²½μ° μ΄ λ¬Έμ κ° λ°μν©λλ€. μΉ μλ²λ μ€ν μ€μΈ μ¬μ©μμ crontabλ§ νμΈν μ μμ΅λλ€. λν PHP λ²μ μ μ¬μ©ν PHP λ°μ΄λ리λ₯Ό κ²°μ ν λ symfony νλ‘μΈμ€ λͺ
λ Ήμ΄ λ§λλ 'μ΅μμ μΆμΈ‘'μ
λλ€. μ€μ ( php7
)μ΄ μλ κ²μ²λΌ νΉμ λ²μ μ μ¬μ©νλ κ²μ μ€λ§νΈνμ§ μμ΅λλ€.
λ΄ /etc/nginx/nginx.conf
λ΄μλ λ€μμ΄ μμ΅λλ€.
λ°λΌμ μΉ μλ² μ¬μ©μλ crontabμ΄ μ€μ λ nginxμΈ κ² κ°μ΅λλ€.
λ΄κ° λλ½λ κ³³μ΄ μμ΅λκΉ?
λν crontabμ΄ λ£¨νΈλ‘ μ€νλκ³ μΉ μλ²κ° www-dataμΈ Debian 10 μ€μΉμμ μ΄κ²μ μ»κ³ μμ΅λλ€.
κ°μ₯ μ μ©ν λκΈ
κ°μ₯ λ¨Όμ νμΈν΄μΌ ν κ²μ ν°λ―Έλμ μμ λμ λΉκ΅νμ¬ 'μΉμλ²'κ° μ€νλλ μ¬μ©μμ λλ€. μ¬μ©μκ° λ€λ₯Έ κ²½μ° μ΄ λ¬Έμ κ° λ°μν©λλ€. μΉ μλ²λ μ€ν μ€μΈ μ¬μ©μμ crontabλ§ νμΈν μ μμ΅λλ€. λν PHP λ²μ μ μ¬μ©ν PHP λ°μ΄λ리λ₯Ό κ²°μ ν λ symfony νλ‘μΈμ€ λͺ λ Ήμ΄ λ§λλ 'μ΅μμ μΆμΈ‘'μ λλ€. μ€μ (
php7
)μ΄ μλ κ²μ²λΌ νΉμ λ²μ μ μ¬μ©νλ κ²μ μ€λ§νΈνμ§ μμ΅λλ€.