-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
44 lines (34 loc) · 1.17 KB
/
Containerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Provide specific arg for setting the version of nodejs to use.
# Should match what's in flake.nix for development.
ARG NODE_MAJOR_VERSION=20
FROM docker.io/node:${NODE_MAJOR_VERSION}-alpine AS base
RUN corepack enable pnpm
# Install dependencies only when needed
FROM base AS deps
# 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
WORKDIR /app
# Install dependencies
COPY package.json pnpm-lock.yaml* .
RUN pnpm install --frozen-lockfile
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the website as standalone output.
RUN pnpm --version && node --version
RUN pnpm run build
# Production image, copy all the files and run next
FROM base AS runner
LABEL maintainer="team@penumbralabs.xyz"
WORKDIR /app
ENV NODE_ENV production
# Create normal user for app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
COPY --from=builder --chown=nodejs:nodejs /app /app
USER nodejs
EXPOSE 3000
ENV PORT 3000
CMD HOSTNAME="0.0.0.0" pnpm start