-
Basically I used the The container is deployed in This is my # This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
ARG NAME_APP
ARG CLIENT_ID
ARG AUTH_SECRET
ARG AUTH_BASE_URL
ARG AUTH_BASE_SERVER_URL
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
COPY . .
RUN turbo prune --scope=auth-app --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
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN yarn global add pnpm
RUN pnpm install
# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
ENV NAME_APP ${NAME_APP}
ENV CLIENT_ID ${CLIENT_ID}
ENV AUTH_SECRET ${AUTH_SECRET}
ENV AUTH_BASE_URL ${AUTH_BASE_URL}
ENV AUTH_BASE_SERVER_URL ${AUTH_BASE_SERVER_URL}
ENV NAME_APP ${NAME_APP}
RUN yarn global add pnpm
RUN pnpm turbo run build --filter=auth-app...
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/auth/next.config.js .
COPY --from=installer /app/auth/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/auth/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/auth/public ./public
COPY --from=installer --chown=nextjs:nodejs /app/auth/.next ./auth/.next
COPY --from=installer --chown=nextjs:nodejs /app/auth/.next/static ./auth/.next/static
EXPOSE 3000
ENV PORT 3000
CMD node auth/server.js
next.config.js/** @type {import('next').NextConfig} */
const path = require("path");
const nextConfig = {
reactStrictMode: true,
transpilePackages: ["sdk"],
output: "standalone",
experimental: {
outputFileTracingRoot: path.join(__dirname, "../"),
},
}
module.exports = nextConfig
estructure
|
Beta Was this translation helpful? Give feedback.
Answered by
wootsbot
Feb 2, 2023
Replies: 2 comments
-
I think I solved this with these lines. # Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/auth/next.config.js .
COPY --from=installer /app/auth/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/auth/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/auth/public ./public
- COPY --from=installer --chown=nextjs:nodejs /app/auth/.next ./auth/.next
+ COPY --from=installer --chown=nextjs:nodejs /app/spin-auth/.next ./.next
COPY --from=installer --chown=nextjs:nodejs /app/auth/.next/static ./auth/.next/static
EXPOSE 3000
ENV PORT 3000
CMD node auth/server.js |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wootsbot
-
But I would be grateful if someone sees if something of this can be optimized |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I solved this with these lines.