-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (46 loc) · 1.75 KB
/
Dockerfile
File metadata and controls
65 lines (46 loc) · 1.75 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
ARG NODE_VERSION=22
FROM ghcr.io/biblioverse/biblioteca-docker:2.0.2 AS base
WORKDIR /var/www/html
USER root
RUN mkdir -p /tmp && chown -R www-data:www-data /tmp && chmod -R 777 /tmp
RUN mkdir -p /var/run/ && chown -R www-data:www-data /var/run && chmod -R 777 /var/run
USER www-data
# We install the dependencies in a separate layer as the frontend image also needs them
FROM base AS vendor
USER root
# Copying the full context is not great for caching
# But composer install executes symfony commands that need the full context
COPY composer.json composer.lock /var/www/html/
RUN composer install --no-interaction --no-progress --no-dev --no-scripts --optimize-autoloader
FROM node:${NODE_VERSION} AS frontend
WORKDIR /var/www/html
# Needed for some symfony specific modules
COPY --from=vendor /var/www/html/vendor /var/www/html/vendor
# Only copy what is needed, improves cacheability
COPY package.json package-lock.json webpack.config.js /var/www/html/
COPY assets/ /var/www/html/assets/
RUN npm install
RUN npm run build
FROM base AS prod
USER root
COPY --chown=www-data:www-data . /var/www/html/
COPY --chown=www-data:www-data --from=vendor /var/www/html/vendor /var/www/html/vendor
COPY --chown=www-data:www-data --from=frontend /var/www/html/public/build /var/www/html/public/build
USER www-data
RUN composer install --no-interaction --no-progress --no-dev --optimize-autoloader
FROM base AS dev
USER root
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
wget \
git \
curl \
sudo \
vim \
nodejs
RUN /usr/local/bin/install-php-extensions xdebug
RUN echo ' \n\
[xdebug] \n\
xdebug.idekey=PHPSTORM \n\
xdebug.mode=off \n\
xdebug.client_host=host.docker.internal\n ' >> /usr/local/etc/php/conf.d/biblioteca.ini
USER www-data