-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
149 lines (115 loc) · 3.87 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
FROM node:20.10-alpine AS assets
WORKDIR /srv/app
ENV FPM_HOST=app
ENV FPM_PORT=9000
# Install dependencies
COPY package.json package-lock.json ./
RUN set -eux; \
npm install; \
npm cache clean --force
# Compile assets
COPY .babelrc .eslintrc.json jest.config.js webpack.config.js ./
COPY assets assets/
RUN set -eux; \
npm run production
# Set up entrypoint
COPY docker/assets-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD ["npm", "run", "watch"]
FROM php:8.2-fpm-bookworm AS app
ARG UID=3302
ARG GID=3302
ENV FPM_HOST=app
ENV FPM_PORT=9000
ARG GITHUB_TOKEN
USER root
RUN rm -rf /srv/app
RUN mkdir -p /srv/app; chown $UID:$GID /srv/app
WORKDIR /srv/app
# Configure app user
RUN groupdel dialout; \
groupadd --gid $GID ben; \
useradd --uid $UID --gid $GID --create-home ben; \
sed -i "s/user = www-data/user = ben/g" /usr/local/etc/php-fpm.d/www.conf; \
sed -i "s/group = www-data/group = ben/g" /usr/local/etc/php-fpm.d/www.conf
# Install persistent & runtime dependencies
RUN set -eux; \
apt-get update; \
apt-get install --no-install-recommends -y git netcat-traditional procps; \
rm -rf /var/lib/apt/lists/*
# Install media utilities
RUN set -eux; \
apt-get update; \
apt-get install --no-install-recommends -y ffmpeg; \
rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN set -eux; \
apt-get update; \
apt-get install --no-install-recommends -y libmagickwand-dev; \
pecl install imagick; \
docker-php-ext-enable imagick; \
rm -rf /var/lib/apt/lists/*
RUN set -eux; \
apt-get update; \
apt-get install --no-install-recommends -y libicu-dev; \
docker-php-ext-install intl; \
rm -rf /var/lib/apt/lists/*
RUN set -eux; \
docker-php-ext-install pdo_mysql
RUN set -eux; \
apt-get update; \
apt-get install --no-install-recommends -y libzip-dev unzip; \
docker-php-ext-install zip; \
rm -rf /var/lib/apt/lists/*
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN if [ ! -z "$GITHUB_TOKEN" ]; then composer config --global github-oauth.github.com $GITHUB_TOKEN; fi
# Set up entrypoints
COPY docker/app-entrypoint.bash /usr/local/bin/app-entrypoint
RUN chmod +x /usr/local/bin/app-entrypoint
COPY docker/php-entrypoint.bash /usr/local/bin/app-php-entrypoint
RUN chmod +x /usr/local/bin/app-php-entrypoint
ENTRYPOINT ["app-entrypoint"]
CMD ["php-fpm"]
USER ben
# Copy application directory contents
COPY --chown=ben:ben license.markdown readme.markdown ./
COPY --chown=ben:ben composer.json composer.lock symfony.lock ./
COPY --chown=ben:ben .env ./
COPY --chown=ben:ben .env.test phpunit.xml.dist ./
COPY --chown=ben:ben bin bin/
COPY --chown=ben:ben config config/
COPY --chown=ben:ben migrations migrations/
COPY --chown=ben:ben public public/
COPY --chown=ben:ben src src/
COPY --chown=ben:ben templates templates/
COPY --chown=ben:ben tests tests/
COPY --chown=ben:ben translations translations/
COPY --from=assets --chown=ben:ben /srv/app/public public/
RUN mkdir -p \
docker/storage/chapters \
docker/storage/covers \
docker/storage/episodes \
docker/storage/shownotes \
docker/storage/transcripts \
public/media \
var/cache \
var/log
# Run Composer commands
RUN set -eux; \
chmod +x bin/console; \
composer install --no-autoloader --no-dev --no-progress --no-scripts; \
composer clear-cache; \
composer dump-autoload --classmap-authoritative; \
APP_ENV=prod bin/console cache:warmup; \
APP_ENV=prod composer run-script post-install-cmd
FROM nginx:alpine AS web
ENV FPM_HOST=app
ENV FPM_PORT=9000
WORKDIR /srv/app
# Copy Nginx configuration
RUN rm /etc/nginx/conf.d/default.conf
COPY docker/nginx/app.conf.template /etc/nginx/templates/
# Copy application directory contents
COPY --from=app /srv/app/public public/