From e0cdc3e7c57ffe43b649e825fce80e20bd8c598a Mon Sep 17 00:00:00 2001
From: Louis Lam <louislam@users.noreply.github.com>
Date: Mon, 29 Aug 2022 22:06:47 +0800
Subject: [PATCH] Update dockerfile for pr-test

---
 docker/dockerfile | 30 ++++++++++++++++++++++++++++++
 package.json      |  1 +
 2 files changed, 31 insertions(+)

diff --git a/docker/dockerfile b/docker/dockerfile
index a9984351b..117c0f12f 100644
--- a/docker/dockerfile
+++ b/docker/dockerfile
@@ -24,6 +24,36 @@ CMD ["node", "server/server.js"]
 FROM release AS nightly
 RUN npm run mark-as-nightly
 
+# Build an image for testing pr
+FROM louislam/uptime-kuma:base-debian AS pr-test
+
+WORKDIR /app
+
+ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
+
+## Install GitHub CLI
+RUN apt update \
+    && apt --yes --no-install-recommends install curl \
+    && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
+    && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
+    && 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 \
+    && apt update \
+    && apt install gh -y
+
+## Empty the directory, because we have to clone the Git repo.
+RUN rm -rf ./* && chown node /app
+
+USER node
+
+RUN git clone https://github.com/louislam/uptime-kuma.git .
+RUN npm ci
+
+EXPOSE 3000 3001
+VOLUME ["/app/data"]
+HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD node extra/healthcheck.js
+ENTRYPOINT ["/usr/bin/dumb-init", "--", "extra/entrypoint.sh"]
+CMD ["npm", "run", "dev"]
+
 
 # Upload the artifact to Github
 FROM louislam/uptime-kuma:base-debian AS upload-artifact
diff --git a/package.json b/package.json
index 981ca1912..df93281af 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,7 @@
         "build-docker-nightly": "npm run build && docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push",
         "build-docker-nightly-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly-alpine --target nightly . --push",
         "build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
+        "build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push",
         "upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
         "setup": "git checkout 1.17.1 && npm ci --production && npm run download-dist",
         "download-dist": "node extra/download-dist.js",