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-05-03 08:06:55 +00:00
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER
|
2022-12-01 18:58:31 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
# 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-05-03 08:06:55 +00:00
|
|
|
ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
|
2023-09-04 13:16:10 +00:00
|
|
|
ARG NEXT_PUBLIC_DEPLOY_URL=http://localhost/spaces
|
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
|
2023-05-03 08:06:55 +00:00
|
|
|
COPY replace-env-vars.sh /usr/local/bin/
|
|
|
|
USER root
|
|
|
|
RUN chmod +x /usr/local/bin/replace-env-vars.sh
|
2022-12-01 18:58:31 +00:00
|
|
|
|
2023-09-04 13:16:10 +00:00
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
|
|
|
|
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
|
|
|
|
NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL
|
|
|
|
|
2023-09-03 13:20:30 +00:00
|
|
|
RUN yarn turbo run build --filter=web
|
2022-12-12 20:36:25 +00:00
|
|
|
|
2023-09-03 13:20:30 +00:00
|
|
|
RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL} web
|
2023-05-03 08:06:55 +00:00
|
|
|
|
2022-12-12 20:36:25 +00:00
|
|
|
FROM node:18-alpine AS runner
|
2022-12-01 18:58:31 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Don't run production as root
|
|
|
|
RUN addgroup --system --gid 1001 plane
|
|
|
|
RUN adduser --system --uid 1001 captain
|
|
|
|
USER captain
|
|
|
|
|
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
|
2023-09-03 13:20:30 +00:00
|
|
|
COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./
|
2023-05-03 08:06:55 +00:00
|
|
|
|
2023-09-03 13:20:30 +00:00
|
|
|
COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next
|
2023-05-03 08:06:55 +00:00
|
|
|
|
|
|
|
ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
|
2023-09-04 13:16:10 +00:00
|
|
|
ARG NEXT_PUBLIC_DEPLOY_URL=http://localhost/spaces
|
|
|
|
|
2023-05-03 08:06:55 +00:00
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
|
2023-09-04 13:16:10 +00:00
|
|
|
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
|
|
|
|
NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL
|
2023-05-03 08:06:55 +00:00
|
|
|
|
|
|
|
USER root
|
|
|
|
COPY replace-env-vars.sh /usr/local/bin/
|
|
|
|
COPY start.sh /usr/local/bin/
|
|
|
|
RUN chmod +x /usr/local/bin/replace-env-vars.sh
|
|
|
|
RUN chmod +x /usr/local/bin/start.sh
|
|
|
|
|
|
|
|
USER captain
|
2022-12-01 18:58:31 +00:00
|
|
|
|
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
|