Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

FROM backend-base as backend-dev
FROM backend-base AS backend-dev

ARG PHP_VERSION

Expand All @@ -27,7 +27,7 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Pre-deployment container. The deployed container needs some files generated by yarn
# Pre-deployment container. The deployed container needs generated frontend assets.
FROM backend-base AS backend-deployment

ARG PHP_VERSION
Expand Down Expand Up @@ -62,20 +62,22 @@ RUN COMPOSER_ALLOW_SUPERUSER=1 composer dump-autoload --optimize --classmap-auth
############
# Frontend #
############
# For some reason, yarn install hangs on node:alpine when building for ARM, so use the normal image instead
# Bigger and slower unfortunately but it works
# Use the normal Node image rather than Alpine for more consistent ARM builds.
# Bigger and slower unfortunately, but it works.
FROM node:latest AS frontend-installer

WORKDIR /application

COPY package.json .
COPY yarn.lock .
COPY package-lock.json .

RUN yarn install --immutable
RUN npm ci

COPY tailwind.config.js postcss.config.js ./
COPY assets/ ./assets/
COPY templates/ ./templates/

RUN yarn build:css
RUN npm run build:css

## Actual deployable frontend image
FROM nginx:alpine AS frontend-deployment
Expand All @@ -89,8 +91,8 @@ RUN sed -i "s/# %DEPLOYMENT //g" /etc/nginx/conf.d/default.conf \
&& sed -i "s/listen 443/#listen 443/g" /etc/nginx/conf.d/default.conf \
&& sed -i "s/ssl_/#ssl_/g" /etc/nginx/conf.d/default.conf

COPY --from=frontend-installer node_modules/@bower_components public/vendor
COPY --from=frontend-installer /public/css public/css
COPY --from=frontend-installer /application/node_modules/font-awesome public/vendor/font-awesome
COPY --from=frontend-installer /application/public/css public/css

COPY public/js public/js
COPY public/images public/images
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ install-assets-dev:
composer-install:
$(PHP_RUN) composer -o install

yarn-install:
npm-install:
docker run \
--rm \
-t \
-v "`pwd`:/workdir" \
-w /workdir \
node:alpine \
sh -c "yarn install --immutable"
npm ci

build-css:
docker run \
Expand All @@ -77,9 +77,9 @@ build-css:
-v "`pwd`:/workdir" \
-w /workdir \
node:alpine \
sh -c "yarn install && yarn build:css"
sh -c "npm ci && npm run build:css"

install-dependencies: composer-install yarn-install build-css
install-dependencies: composer-install npm-install build-css

composer-update:
$(PHP_RUN) composer update --no-scripts
Expand Down
Loading