dispatch-server deploy
This commit is contained in:
@@ -1,29 +1,48 @@
|
||||
FROM node:22-alpine
|
||||
FROM node:22-alpine AS base
|
||||
|
||||
ENV PNPM_HOME="/usr/local/pnpm"
|
||||
ENV PATH="${PNPM_HOME}:${PATH}"
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
RUN pnpm add -g turbo@^2.5
|
||||
|
||||
FROM base AS builder
|
||||
RUN apk update
|
||||
RUN apk add --no-cache libc6-compat
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/app
|
||||
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Change ownership to the non-root user
|
||||
RUN chown -R node:node /usr/app
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
RUN turbo prune dispatch-server --docker
|
||||
|
||||
FROM base AS installer
|
||||
RUN apk update
|
||||
RUN apk add --no-cache libc6-compat
|
||||
|
||||
WORKDIR /usr/app
|
||||
|
||||
COPY --from=builder /usr/app/out/json/ .
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Build the project
|
||||
COPY --from=builder /usr/app/out/full/ .
|
||||
|
||||
RUN turbo run build
|
||||
|
||||
FROM base AS runner
|
||||
WORKDIR /usr/app
|
||||
|
||||
# Don't run production as root
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
USER nextjs
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=installer --chown=nextjs:nodejs /usr/app/ ./
|
||||
|
||||
# Expose the application port
|
||||
EXPOSE 3002
|
||||
|
||||
# Run container as non-root (unprivileged) user
|
||||
# The "node" user is provided in the Node.js Alpine base image
|
||||
USER node
|
||||
|
||||
# Command to run the application
|
||||
CMD ["node", "index.js"]
|
||||
CMD ["pnpm", "--dir", "apps/dispatch-server", "run", "start"]
|
||||
Reference in New Issue
Block a user