2023-01-19 18:07:55 +01:00
|
|
|
FROM --platform=${BUILDPLATFORM} docker.io/node:alpine as builder
|
2021-09-30 04:31:39 +02:00
|
|
|
RUN apk add --no-cache git python3 build-base
|
2023-01-11 19:55:28 +01:00
|
|
|
|
2021-03-08 17:02:04 +01:00
|
|
|
WORKDIR /app
|
2023-01-11 19:55:28 +01:00
|
|
|
|
|
|
|
# Copy package.json and yarn.lock and install dependencies first to speed up subsequent builds
|
|
|
|
COPY package.json yarn.lock /app/
|
|
|
|
RUN yarn install
|
|
|
|
|
|
|
|
COPY . /app
|
|
|
|
RUN yarn build
|
2021-03-08 17:02:04 +01:00
|
|
|
|
2023-01-20 14:31:14 +01:00
|
|
|
# Because we will be running as an unprivileged user, we need to make sure that the config file is writable
|
|
|
|
# So, we will copy the default config to the /tmp folder that will be writable at runtime
|
|
|
|
RUN mv -f target/config.json /config.json.bundled \
|
|
|
|
&& ln -sf /tmp/config.json target/config.json
|
|
|
|
|
|
|
|
FROM --platform=${BUILDPLATFORM} docker.io/nginxinc/nginx-unprivileged:alpine
|
2023-01-11 19:06:25 +01:00
|
|
|
|
|
|
|
# Copy the dynamic config script
|
|
|
|
COPY ./docker/dynamic-config.sh /docker-entrypoint.d/99-dynamic-config.sh
|
2023-01-20 14:31:14 +01:00
|
|
|
# And the bundled config file
|
|
|
|
COPY --from=builder /config.json.bundled /config.json.bundled
|
2023-01-11 19:06:25 +01:00
|
|
|
|
|
|
|
# Copy the built app from the first build stage
|
2021-03-08 17:02:04 +01:00
|
|
|
COPY --from=builder /app/target /usr/share/nginx/html
|