-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
41 lines (35 loc) · 1.04 KB
/
dockerfile
File metadata and controls
41 lines (35 loc) · 1.04 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
# Stage 1: Decide base image
# 決定基底映像檔
FROM alpine:latest AS builder
RUN apk add --no-cache tzdata
RUN apk add --no-cache --update nodejs npm
# Stage 2: Set Timezone
# 設定容器時區
ENV TZ=Asia/Taipei
RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Stage 3: Set the working directory
# 設置目前工作目錄
WORKDIR /src
# Stage 4: Install requirements
# 複製檔案至映像檔內
COPY . .
# 安裝 Dependencies
RUN npm install -g npm@10.2.2
# 只安裝 dependencies 的套件
RUN npm install --production && npm cache clean --force
# 生成 Prisma Client
RUN npx prisma generate --schema=./prisma/schema.prisma
# 建立 log 資料夾
RUN mkdir -p /src/logs/error && mkdir -p /src/logs/info
# 把安裝好的全部移過去
FROM alpine:latest
RUN apk add --no-cache --update nodejs npm
WORKDIR /src
COPY --from=builder /src .
# Stage 5: Set container listen Port
# 設定 Docker 要開放的 Port
# restful api server
EXPOSE 3000
# Stage 6: Run app
# 啟動 Container 時要執行的指令
CMD [ "node", "app" ]