/
Dockerfile.ember
60 lines (50 loc) · 1.92 KB
/
Dockerfile.ember
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
FROM danlynn/ember-cli:4.12.1 as build
# Copy pnpm relevant files from all apps in workspace
COPY package.json pnpm-*.yaml /myapp/
COPY ember-caluma-portal/package.json /myapp/ember-caluma-portal/
COPY ember-camac-ng/package.json /myapp/ember-camac-ng/
COPY ember-ebau/package.json /myapp/ember-ebau/
COPY ember-ebau-core/package.json /myapp/ember-ebau-core/
# Fetch all workspace dependencies
RUN --mount=type=cache,target=.pnpm-store,sharing=locked \
corepack enable && \
pnpm config set store-dir .pnpm-store && \
pnpm fetch
COPY . /myapp/
# Install dependencies, this should not need to fetch any dependencies as they
# are fetched into the pnpm store beforehand
RUN pnpm install --recursive --frozen-lockfile
ARG APP_ENV=production
ARG APPLICATION
ARG BE_GIS_URL
ARG DEPLOY_TARGET=production
ARG EGOV_PORTAL_URL
ARG INTERNAL_HOST_ARG
ARG INTERNAL_URL
ARG KEYCLOAK_HOST
ARG KEYCLOAK_URL_ARG
ARG PORTAL_URL
ARG SO_GIS_URL
ARG WORKSPACE
ENV INTERNAL_HOST=$INTERNAL_HOST_ARG
ENV KEYCLOAK_URL=$KEYCLOAK_URL_ARG
WORKDIR /myapp/$WORKSPACE
RUN pnpm ember deploy $DEPLOY_TARGET
# Production environment
FROM nginxinc/nginx-unprivileged:1.25-alpine as prod
ARG WORKSPACE
COPY --from=build /myapp/$WORKSPACE/build /usr/share/nginx/html
COPY nginx/ember.conf /etc/nginx/conf.d/default.conf
# Production environment with runtime environment variables (currently only used in SO)
FROM nginxinc/nginx-unprivileged:1.25-alpine as prod-env
ARG WORKSPACE
ARG REPLACE_ENV
ENV REPLACE_ENV_RUNTIME=$REPLACE_ENV
USER root
RUN chown -R nginx:nginx /usr/share/nginx/html
USER nginx
COPY --from=build --chown=nginx:nginx /myapp/$WORKSPACE/build /usr/share/nginx/html
COPY nginx/ember.conf /etc/nginx/conf.d/default.conf
COPY nginx/replace-env-vars.sh /usr/local/bin/replace-env-vars
RUN find /usr/share/nginx/html -iname "*.gz" -o -iname "*.br" | xargs rm -rf
CMD /bin/sh -c "replace-env-vars '$REPLACE_ENV_RUNTIME' /usr/share/nginx/html && nginx -g 'daemon off;'"