-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
165 lines (133 loc) · 4.88 KB
/
Copy pathDockerfile
File metadata and controls
165 lines (133 loc) · 4.88 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
###################################################
# Alias for deppendencies
FROM node:24.9.0 AS node
FROM composer:2.8.8 AS composer
FROM dunglas/frankenphp:1.4.4-php8.4 AS frankenphp
###################################################
################ FRONTEND STAGES ################
###################################################
###################################################
FROM node AS frontend-base
WORKDIR /app/frontend
# install dependencies
COPY frontend/package.json \
frontend/svelte.config.js \
frontend/vite.config.ts \
frontend/.prettierrc frontend/.prettierignore \
frontend/tsconfig.json /app/frontend/
# copy code
COPY frontend/src /app/frontend/src
COPY frontend/static /app/frontend/static
COPY shared /app/shared
###################################################
FROM frontend-base AS frontend-dev
RUN npm install
CMD ["npm", "run", "dev"]
###################################################
FROM frontend-base AS frontend-prod
# build the frontend
RUN npm install \
&& npm run build \
&& find . -maxdepth 1 -not -name build -not -name . -exec rm -rf {} \;
###################################################
################ ARCHIVE STAGES ################
###################################################
###################################################
FROM node AS archive-base
WORKDIR /app/archive
# install dependencies
COPY archive/package.json archive/package-lock.json \
archive/svelte.config.js \
archive/vite.config.ts \
archive/.prettierrc archive/.prettierignore \
archive/tsconfig.json /app/archive/
# copy code
COPY archive/src /app/archive/src
COPY archive/static /app/archive/static
COPY shared /app/shared
###################################################
FROM archive-base AS archive-dev
COPY archive/.env /app/archive/
RUN npm install
CMD ["npm", "run", "dev"]
###################################################
FROM archive-base AS archive-prod
# build the archive
RUN npm install \
&& npm run build \
&& find . -maxdepth 1 \
-not -name build \
-not -name node_modules \
-not -name package.json \
-not -name . \
-exec rm -rf {} \;
###################################################
################ EMBED STAGES ################
###################################################
###################################################
FROM node AS embed-base
WORKDIR /app/embed
# install dependencies
COPY embed/package.json embed/package-lock.json \
embed/vite.config.ts \
embed/tsconfig.json \
embed/tsconfig.app.json \
embed/tsconfig.node.json \
embed/.prettierrc embed/.prettierignore \
/app/embed/
COPY embed/src /app/embed/src
###################################################
FROM embed-base AS embed-dev
EXPOSE 80
RUN npm install
CMD ["npm", "run", "dev"]
###################################################
FROM embed-base AS embed-prod
# build the embed
RUN npm install \
&& npm run build \
&& find . -maxdepth 1 -not -name dist -not -name . -exec rm -rf {} \;
###################################################
################ BACKEND STAGES #################
###################################################
###################################################
FROM frankenphp AS backend-base
WORKDIR /app/backend
# install php and dependencies
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
RUN install-php-extensions zip intl pdo_pgsql opcache apcu
RUN apt update && apt install -y supervisor
###################################################
FROM backend-base AS backend-dev
# pcov for coverage
RUN install-php-extensions pcov
COPY backend/composer.json backend/composer.lock /app/backend/
RUN composer install --no-interaction
# set up code and install composer packages
COPY backend /app/backend/
COPY shared /app/shared/
COPY meta/image/dev/Caddyfile.dev /etc/caddy/Caddyfile
COPY meta/image/dev/supervisord.dev.conf /etc/supervisor/conf.d/supervisord.conf
COPY meta/image/dev/php.dev.ini /usr/local/etc/php/conf.d/app.ini
COPY meta/image/dev/run.dev /app/run
CMD ["sh", "/app/run"]
###################################################
FROM backend-base AS final
# supervisor
# nodejs for archive
RUN apt update \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt install -y nodejs
COPY backend /app/backend
COPY shared /app/shared
RUN composer install --no-cache --prefer-dist --no-dev --no-scripts --no-progress
# Copy Frontend, Embed and Archive builds
COPY --from=frontend-prod /app/frontend/build /app/static
COPY --from=embed-prod /app/embed/dist /app/static/form
COPY --from=archive-prod /app/archive/ /app/archive
COPY meta/image/prod/Caddyfile.prod /etc/caddy/Caddyfile
COPY meta/image/prod/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY meta/image/prod/php.prod.ini /usr/local/etc/php/conf.d/app.ini
COPY meta/image/prod/run.prod /app/run
EXPOSE 80
CMD ["sh", "/app/run"]