blfm commited on
Commit
39a877f
·
verified ·
1 Parent(s): aa39c8d

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +113 -0
Dockerfile ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ARG BASE_IMAGE=louislam/uptime-kuma:base2
2
+
3
+ ############################################
4
+ # Build in Golang
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
+ # Build in Node.js
12
+ ############################################
13
+ FROM louislam/uptime-kuma:base2 AS build
14
+ USER node
15
+ WORKDIR /app
16
+
17
+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
18
+ COPY --chown=node:node .npmrc .npmrc
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
+ # ⭐ Main Image
28
+ ############################################
29
+ FROM $BASE_IMAGE AS release
30
+ USER node
31
+ WORKDIR /app
32
+
33
+ LABEL org.opencontainers.image.source="https://github.com/louislam/uptime-kuma"
34
+
35
+ ENV UPTIME_KUMA_IS_CONTAINER=1
36
+
37
+ # Copy app files from build layer
38
+ COPY --chown=node:node --from=build /app /app
39
+
40
+ EXPOSE 3001
41
+ HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck
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
+ USER node
79
+ RUN git config --global user.email "[email protected]"
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
+ # Dist only
112
+ RUN cd /app && tar -zcvf $DIST dist
113
+ RUN /app/extra/upload-github-release-asset.sh github_api_token=$GITHUB_TOKEN owner=louislam repo=uptime-kuma tag=$VERSION filename=/app/$DIST