-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
89 lines (66 loc) · 2.63 KB
/
Dockerfile
File metadata and controls
89 lines (66 loc) · 2.63 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
# Alias for deppendencies
FROM node:22.12.0 AS node
FROM composer:2.8.4 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/package-lock.json \
frontend/svelte.config.js \
frontend/vite.config.ts \
frontend/tsconfig.json .
# copy code
COPY frontend/src ./src
COPY frontend/static ./static
###################################################
FROM frontend-base AS frontend-dev
RUN npm install
RUN if [ -d "src/design" ]; then cd src/design && npm link && cd ../.. && npm link @hyvor/design; fi
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 {} \;
###################################################
################ BACKEND STAGES #################
###################################################
###################################################
FROM frankenphp AS backend-base
WORKDIR /app/backend
ENV APP_RUNTIME "Runtime\FrankenPhpSymfony\Runtime"
# 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
# symfony cli
RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | bash \
&& apt install -y symfony-cli
# pcov for coverage
RUN install-php-extensions pcov
COPY backend /app/backend/
# set up code and install composer packages
RUN composer install --no-interaction
COPY meta/image/dev/Caddyfile.dev /etc/caddy/Caddyfile
COPY meta/image/dev/supervisord.conf.dev /etc/supervisor/conf.d/supervisord.conf
COPY meta/image/dev/run.dev /app/run
CMD ["sh", "/app/run"]
###################################################
FROM backend-base AS final
ENV APP_ENV=prod \
APP_DEBUG=0
COPY backend /app/backend
RUN composer install --no-interaction --no-dev --optimize-autoloader --classmap-authoritative --no-scripts
COPY --from=frontend-prod /app/frontend/build /app/static
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/run.prod /app/run
EXPOSE 80
CMD ["sh", "/app/run"]