# ---------------------------------
# BUILD STAGE
# ---------------------------------
FROM node:18-alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . ./
RUN turbo prune --scope=webapp --docker
# ---------------------------------
# ---------------------------------
# INSTALL STAGE
# ---------------------------------
# Add lockfile and package.json's of isolated subworkspace
FROM node:18-alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ ./
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install
# Install doppler and provide the doppler token so the ENV variables can be statically replaced in the react+vite app.
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/[email protected]
RUN echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories
RUN apk add doppler
ENV DOPPLER_TOKEN=${DOPPLER_TOKEN}
COPY --from=builder /app/out/full/ ./
COPY turbo.json turbo.json
RUN yarn turbo run build --filter=webapp...
# ---------------------------------
# ---------------------------------
# RUNNER STAGE (NGINX)
# ---------------------------------
FROM nginx:1.25-alpine
COPY --from=installer /app/apps/webapp/nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=installer /app/apps/webapp/dist /usr/share/nginx/html
EXPOSE 80
# -------------------------------------