-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (38 loc) · 1.28 KB
/
Dockerfile
File metadata and controls
55 lines (38 loc) · 1.28 KB
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
45
46
47
48
49
50
51
52
53
54
55
FROM node:22-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Set the Temp Working Directory inside the container
WORKDIR /temp-deps
RUN npm install -g pnpm@latest-10
# copy package json
COPY ["package.json", "pnpm-lock.yaml", "./"]
RUN pnpm install --frozen-lockfile
FROM base AS builder
# Set the Temp Working Directory inside the container
WORKDIR /temp-build
# copy base code
COPY . .
# copy environment
RUN cp .env.example .env
COPY --from=deps /temp-deps/node_modules ./node_modules
RUN npm install -g pnpm@latest-10
# prune devDependencies
RUN pnpm build && pnpm install --production --ignore-scripts --prefer-offline
# image runner app
FROM base AS runner
# Set the Current Working Directory inside the container
WORKDIR /app
ENV NODE_ENV=production
# editor cli with nano
RUN apk add nano
COPY --from=builder /temp-build/public ./public
COPY --from=builder /temp-build/node_modules ./node_modules
COPY --from=builder /temp-build/package.json ./package.json
COPY --from=builder /temp-build/script ./script
COPY --from=builder /temp-build/logs ./logs
COPY --from=builder /temp-build/dist ./dist
COPY --from=builder /temp-build/.env ./.env
# This container exposes port 8000 to the outside world
EXPOSE 8000
# Run for production
CMD ["yarn", "start:production"]