2024-01-09 17:20:51 +00:00
|
|
|
# ******************************************
|
|
|
|
# STAGE 1: Build the project
|
|
|
|
# ******************************************
|
2022-12-12 20:36:25 +00:00
|
|
|
FROM node:18-alpine AS builder
|
2022-12-01 18:58:31 +00:00
|
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
# Set working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
2023-02-21 06:01:43 +00:00
|
|
|
RUN yarn global add turbo
|
|
|
|
COPY . .
|
2022-12-01 18:58:31 +00:00
|
|
|
|
2023-09-03 13:20:30 +00:00
|
|
|
RUN turbo prune --scope=web --docker
|
2022-12-01 18:58:31 +00:00
|
|
|
|
2024-01-09 17:20:51 +00:00
|
|
|
|
|
|
|
# ******************************************
|
|
|
|
# STAGE 2: Install dependencies & build the project
|
|
|
|
# ******************************************
|
2022-12-01 18:58:31 +00:00
|
|
|
# Add lockfile and package.json's of isolated subworkspace
|
2022-12-12 20:36:25 +00:00
|
|
|
FROM node:18-alpine AS installer
|
2022-12-01 18:58:31 +00:00
|
|
|
|
|
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
WORKDIR /app
|
2023-09-13 14:51:02 +00:00
|
|
|
ARG NEXT_PUBLIC_API_BASE_URL=""
|
|
|
|
ARG NEXT_PUBLIC_DEPLOY_URL=""
|
2022-12-01 18:58:31 +00:00
|
|
|
|
|
|
|
# First install the dependencies (as they change less often)
|
|
|
|
COPY .gitignore .gitignore
|
|
|
|
COPY --from=builder /app/out/json/ .
|
2023-02-21 06:01:43 +00:00
|
|
|
COPY --from=builder /app/out/yarn.lock ./yarn.lock
|
2023-06-30 04:23:44 +00:00
|
|
|
RUN yarn install --network-timeout 500000
|
2022-12-01 18:58:31 +00:00
|
|
|
|
|
|
|
# Build the project
|
|
|
|
COPY --from=builder /app/out/full/ .
|
|
|
|
COPY turbo.json turbo.json
|
2024-04-08 09:31:17 +00:00
|
|
|
|
2023-09-13 14:51:02 +00:00
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
|
|
|
|
ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL
|
2023-09-04 13:16:10 +00:00
|
|
|
|
2023-09-03 13:20:30 +00:00
|
|
|
RUN yarn turbo run build --filter=web
|
2022-12-12 20:36:25 +00:00
|
|
|
|
2024-01-09 17:20:51 +00:00
|
|
|
|
|
|
|
# ******************************************
|
|
|
|
# STAGE 3: Copy the project and start it
|
|
|
|
# ******************************************
|
|
|
|
|
2022-12-12 20:36:25 +00:00
|
|
|
FROM node:18-alpine AS runner
|
2022-12-01 18:58:31 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2023-09-03 13:20:30 +00:00
|
|
|
COPY --from=installer /app/web/next.config.js .
|
|
|
|
COPY --from=installer /app/web/package.json .
|
2022-12-01 18:58:31 +00:00
|
|
|
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
2024-04-08 09:31:17 +00:00
|
|
|
COPY --from=installer /app/web/.next/standalone ./
|
|
|
|
COPY --from=installer /app/web/.next ./web/.next
|
|
|
|
COPY --from=installer /app/web/public ./web/public
|
2023-05-03 08:06:55 +00:00
|
|
|
|
2023-09-13 14:51:02 +00:00
|
|
|
ARG NEXT_PUBLIC_API_BASE_URL=""
|
|
|
|
ARG NEXT_PUBLIC_DEPLOY_URL=""
|
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
|
|
|
|
ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL
|
2023-05-03 08:06:55 +00:00
|
|
|
|
|
|
|
COPY start.sh /usr/local/bin/
|
|
|
|
RUN chmod +x /usr/local/bin/start.sh
|
|
|
|
|
2023-02-21 06:01:43 +00:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2022-12-12 20:36:25 +00:00
|
|
|
|
2023-02-21 06:01:43 +00:00
|
|
|
EXPOSE 3000
|