forked from drupal-composer/drupal-project
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
76 lines (52 loc) · 2.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# For copying compiled node.
FROM node:18-buster as node-env
# Copy everything in and chown to www-data
COPY /docroot/themes/custom/NAMEOFTHEME /
RUN yarn install
RUN yarn build
# Build from our prepared Drupal image.
FROM registry.codekoalas.com/devops/helm/koality-charts/drupal10/php-8.2:0.1.1 as cli
RUN mkdir -p /opt/drupal/web
RUN chown -R www-data:www-data /opt/drupal/web
COPY --chown=www-data:www-data ./ /opt/drupal/web
COPY --from=node-env / /opt/drupal/web/docroot/themes/custom/NAMEOFTHEME
# Enable PDF generation
RUN sed -i 's/rights="none" pattern="PDF"/rights="read" pattern="PDF"/g' /etc/ImageMagick-7/policy.xml
WORKDIR /opt/drupal/web
# Create directory for PID file.
RUN mkdir -p /var/run/php
RUN mkdir -p /var/log/php-fpm
# Composer install packages. We use su-exec so the command run directly as if the user
# was www-data, and not as root. This also prevents odd interactions with TTY and signals
# and also doesn’t require us to swap back and forth between users.
RUN su-exec www-data composer install --no-interaction --no-progress --optimize-autoloader --no-dev --ignore-platform-reqs
COPY /docker/supervisor-codekoalas-conf.ini /etc/supervisor.d/
# We need to add our NGINX template to the container for startup,
# and configuration. Apply envsubst to substitute environment variables inside the
# NGINX conf file.
COPY /docker/nginx.conf.template /etc/nginx/nginx.conf.template
# Copy MSMTPRC template to /etc.
COPY /docker/msmtprc.template /etc/msmtprc.template
# Customize some PHP settings.
COPY /docker/php.ini $PHP_INI_DIR/conf.d/zzz-codekoalas-settings.ini
# Now let's override some PHP FPM settings.
COPY /docker/php-fpm.conf /usr/local/etc/php-fpm.d/zzz-codekoalas.conf
# Configure cron.
COPY /docker/crontab.tab /etc/crontab.tab
RUN /usr/bin/crontab /etc/crontab.tab
RUN htpasswd -cb /etc/nginx/.htpasswd drupal koality
EXPOSE 80
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
# We need a CRON container to run the Drupal Cron.
# We'll start with the CLI container as our base,
# as we only need to override the CMD which the container starts with to point at cron
FROM cli as cron
WORKDIR /opt/drupal/web
# We want to create a drupal.cron file with Drupal drush cron settings, which we can import into crontab,
# and run crond as the primary command in the foreground
RUN touch drupal.cron && \
echo "* * * * * cd /opt/drupal/web/docroot; ./vendor/drush/drush/drush --quiet cron >> /dev/null 2>&1" >> drupal.cron && \
crontab drupal.cron
CMD ["crond", "-f", "-l", "8"]
# This tells Docker the default build is "cli"
FROM cli