-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (49 loc) · 1.84 KB
/
Dockerfile
File metadata and controls
67 lines (49 loc) · 1.84 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
FROM php:8.4-alpine AS server
# PHP Extensions installer
# Extracting it from official image
# It helps us to install PHP extension via PECL and automatically installs required system libraries, and uninstalls buildtime-only libraries
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
# Composer 2 + Basic extensions
# mbstring and curl (and maybe more extensions) are already shipped with PHP
RUN install-php-extensions @composer-2 opcache zip intl sockets protobuf pdo_pgsql redis
# Extracting RoadRunner binary from official image
COPY --from=ghcr.io/roadrunner-server/roadrunner:2025 /usr/bin/rr /usr/local/bin/rr
# Exposing port
EXPOSE 8080/tcp
# Creating user and group that handle application itself
RUN addgroup -S app && adduser -S app -G app
# Making working directory and giving permissions on it
RUN mkdir -p /app && chown app:app /app && chmod 700 /app
WORKDIR /app
# Setting basic Symfony environment variables
ENV APP_ENV="prod"
ENV APP_DEBUG="0"
# Switching to NodeJS app build context (layer)
FROM node:22-alpine AS node_build
# Copying package.json
WORKDIR /app
COPY ./package*.json .
# Installing dependencies
RUN npm ci
# App specific actions to build an app
COPY webpack.config.js ./
COPY assets/ ./assets
RUN mkdir -p public/build
RUN npm run build
# Cleaning up
RUN rm -rf node_modules/ assets/
# Returning to server context
FROM server
# Copying assets from built app layer via NodeJS
COPY --from=node_build --chown=app:app /app/public/build ./public/build
# Copying other files from an app
# Some files you need to exclude via .dockerignore
# Also we are setting up owner of files
COPY --chown=app:app . .
# Preparing image before start
USER app
RUN mkdir -p var/cache var/log
# Installing dependecies
RUN composer install --optimize-autoloader --no-dev
# Running server
CMD ["sh", "./server.sh"]