-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathDockerfile
51 lines (36 loc) · 1.21 KB
/
Dockerfile
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
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
# copy package json
COPY ["package.json", "yarn.lock", "./"]
RUN yarn 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
# prune devDependencies
RUN yarn build && yarn 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"]