Update Dockerfile
Browse files- Dockerfile +22 -103
Dockerfile
CHANGED
@@ -1,113 +1,32 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
# Run npm run build-healthcheck-armv7 in the host first, otherwise it will be super slow where it is building the armv7 healthcheck
|
6 |
-
# Check file: builder-go.dockerfile
|
7 |
-
############################################
|
8 |
-
FROM louislam/uptime-kuma:builder-go AS build_healthcheck
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
############################################
|
13 |
-
FROM louislam/uptime-kuma:base2 AS build
|
14 |
-
USER node
|
15 |
-
WORKDIR /app
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
COPY --chown=node:node package.json package.json
|
20 |
-
COPY --chown=node:node package-lock.json package-lock.json
|
21 |
-
RUN npm ci --omit=dev
|
22 |
-
COPY . .
|
23 |
-
COPY --chown=node:node --from=build_healthcheck /app/extra/healthcheck /app/extra/healthcheck
|
24 |
-
RUN mkdir ./data
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
############################################
|
29 |
-
FROM $BASE_IMAGE AS release
|
30 |
-
USER node
|
31 |
-
WORKDIR /app
|
32 |
|
33 |
-
|
|
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
43 |
-
CMD ["node", "server/server.js"]
|
44 |
-
|
45 |
-
############################################
|
46 |
-
# Rootless Image
|
47 |
-
############################################
|
48 |
-
FROM release AS rootless
|
49 |
-
|
50 |
-
############################################
|
51 |
-
# Mark as Nightly
|
52 |
-
############################################
|
53 |
-
FROM release AS nightly
|
54 |
-
RUN npm run mark-as-nightly
|
55 |
-
|
56 |
-
FROM nightly AS nightly-rootless
|
57 |
-
USER node
|
58 |
-
|
59 |
-
############################################
|
60 |
-
# Build an image for testing pr
|
61 |
-
############################################
|
62 |
-
FROM louislam/uptime-kuma:base2 AS pr-test2
|
63 |
-
WORKDIR /app
|
64 |
-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
|
65 |
-
|
66 |
-
## Install Git
|
67 |
-
RUN apt update \
|
68 |
-
&& apt --yes --no-install-recommends install curl \
|
69 |
-
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
70 |
-
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
|
71 |
-
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
72 |
-
&& apt update \
|
73 |
-
&& apt --yes --no-install-recommends install git
|
74 |
-
|
75 |
-
## Empty the directory, because we have to clone the Git repo.
|
76 |
-
RUN rm -rf ./* && chown node /app
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
RUN git config --global user.name "PR Tester"
|
81 |
-
RUN git clone https://github.com/louislam/uptime-kuma.git .
|
82 |
-
RUN npm ci
|
83 |
-
|
84 |
-
EXPOSE 3000 3001
|
85 |
-
HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck
|
86 |
-
CMD ["npm", "run", "start-pr-test"]
|
87 |
-
|
88 |
-
############################################
|
89 |
-
# Upload the artifact to Github
|
90 |
-
############################################
|
91 |
-
FROM louislam/uptime-kuma:base2 AS upload-artifact
|
92 |
-
WORKDIR /
|
93 |
-
RUN apt update && \
|
94 |
-
apt --yes install curl file
|
95 |
-
|
96 |
-
COPY --from=build /app /app
|
97 |
-
|
98 |
-
ARG VERSION
|
99 |
-
ARG GITHUB_TOKEN
|
100 |
-
ARG TARGETARCH
|
101 |
-
ARG PLATFORM=debian
|
102 |
-
ARG FILE=$PLATFORM-$TARGETARCH-$VERSION.tar.gz
|
103 |
-
ARG DIST=dist.tar.gz
|
104 |
-
|
105 |
-
RUN chmod +x /app/extra/upload-github-release-asset.sh
|
106 |
-
|
107 |
-
# Full Build
|
108 |
-
# RUN tar -zcvf $FILE app
|
109 |
-
# RUN /app/extra/upload-github-release-asset.sh github_api_token=$GITHUB_TOKEN owner=louislam repo=uptime-kuma tag=$VERSION filename=$FILE
|
110 |
|
111 |
-
#
|
112 |
-
|
113 |
-
RUN /app/extra/upload-github-release-asset.sh github_api_token=$GITHUB_TOKEN owner=louislam repo=uptime-kuma tag=$VERSION filename=/app/$DIST
|
|
|
1 |
+
# 使用 Alpine Linux 作为基础镜像,并命名为 builder 阶段
|
2 |
+
FROM alpine AS builder
|
3 |
|
4 |
+
# 安装必要的软件包(Node.js、npm 和 Git)
|
5 |
+
RUN apk add --no-cache nodejs npm git
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# 升级全局安装的 npm 到最新版本
|
8 |
+
RUN npm install npm -g
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
# 创建名为 app 的非交互式用户
|
11 |
+
RUN adduser -D app
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# 切换用户为 app,后续命令将以该用户身份执行
|
14 |
+
USER app
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
# 设置工作目录为 /home/app
|
17 |
+
WORKDIR /home/app
|
18 |
|
19 |
+
# 在 /home/app 目录下克隆指定的 Git 仓库
|
20 |
+
RUN git clone https://github.com/louislam/uptime-kuma.git
|
21 |
|
22 |
+
# 设置工作目录为 /home/app/uptime-kuma
|
23 |
+
WORKDIR /home/app/uptime-kuma
|
24 |
|
25 |
+
# 在 uptime-kuma 项目目录下运行 npm 脚本 setup
|
26 |
+
RUN npm run setup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
# 声明容器将监听的端口
|
29 |
+
EXPOSE 3001
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
# 指定容器启动时要运行的默认命令
|
32 |
+
CMD ["node", "server/server.js"]
|
|