This commit is contained in:
parent
88e0e95e9f
commit
c1fe5f2884
@ -4,7 +4,7 @@ FROM node:20-alpine3.17 AS base
|
|||||||
RUN npm install -g pnpm
|
RUN npm install -g pnpm
|
||||||
ENV PNPM_HOME=/usr/local/bin
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
|
|
||||||
FROM base AS builder
|
FROM base AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy website package and lock files only
|
# Copy website package and lock files only
|
||||||
@ -17,31 +17,6 @@ ENV GIT_REV=${GIT_REV}
|
|||||||
RUN pnpm install --filter website
|
RUN pnpm install --filter website
|
||||||
RUN pnpm run build:website
|
RUN pnpm run build:website
|
||||||
|
|
||||||
# Final stage for running the app
|
|
||||||
FROM base AS runner
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Set environment variables for production
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
# Create system user and group for running the app
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
|
||||||
RUN adduser --system --uid 1001 nextjs
|
|
||||||
|
|
||||||
# Ensure necessary directories exist and are writable
|
|
||||||
RUN mkdir -p /app/website/.next
|
|
||||||
RUN chown nextjs:nodejs /app/website/.next
|
|
||||||
|
|
||||||
# Copy built files from the builder stage
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/website/.next ./website/.next
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/website/public ./website/public
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/website/package.json ./website/package.json
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/website/next.config.mjs ./website/next.config.mjs
|
|
||||||
|
|
||||||
# Switch to non-root user
|
|
||||||
USER nextjs
|
|
||||||
|
|
||||||
# Expose the app port and start it
|
# Expose the app port and start it
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV HOSTNAME="0.0.0.0"
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
Reference in New Issue
Block a user