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
|
|
|
|
|
|
|
RUN turbo prune --scope=app --docker
|
|
|
|
|
|
|
|
# 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
|
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
|
|
|
|
RUN yarn install
|
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-02-21 06:01:43 +00:00
|
|
|
RUN yarn turbo run build --filter=app
|
2022-12-12 20:36:25 +00:00
|
|
|
|
2023-05-03 08:06:55 +00:00
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
|
|
|
|
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
|
|
|
|
|
2023-05-03 11:09:13 +00:00
|
|
|
RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL}
|
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
|
|
|
|
|
|
|
|
COPY --from=installer /app/apps/app/next.config.js .
|
|
|
|
COPY --from=installer /app/apps/app/package.json .
|
|
|
|
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
|
|
|
COPY --from=installer --chown=captain:plane /app/apps/app/.next/standalone ./
|
2023-05-03 08:06:55 +00:00
|
|
|
|
|
|
|
COPY --from=installer --chown=captain:plane /app/apps/app/.next ./apps/app/.next
|
|
|
|
|
|
|
|
ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
|
|
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
|
|
|
|
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
|
|
|
|
|
|
|
|
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
|