diff --git a/.env b/.env new file mode 100644 index 0000000..0716bb0 --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +USE_DEV_COLORS= + +URL_IUS_DIRECT= \ No newline at end of file diff --git a/.gitignore b/.gitignore index d1595af..da2c685 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,6 @@ yarn-debug.log* yarn-error.log* # local env files -.env .env.local .env.development.local .env.test.local diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile new file mode 100644 index 0000000..246ccbf --- /dev/null +++ b/apps/web/Dockerfile @@ -0,0 +1,47 @@ +FROM node:alpine AS builder +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +RUN apk update +# Set working directory +WORKDIR /app +RUN yarn global add turbo +RUN yarn global add dotenv-cli +COPY . . +RUN turbo prune --scope=web --docker + +# Add lockfile and package.json's of isolated subworkspace +FROM node: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 + +# Build the project +COPY --from=builder /app/out/full/ . +COPY turbo.json turbo.json +COPY .env .env +RUN yarn dotenv -e .env turbo run build --filter=web... + +FROM node:alpine AS runner +WORKDIR /app + +# Don't run production as root +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +USER nextjs + +COPY --from=installer /app/apps/web/next.config.js . +COPY --from=installer /app/apps/web/package.json . + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public + +CMD node apps/web/server.js \ No newline at end of file