From 7b4c70860cd38086e556047c7bb0f7d1b8255069 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Fri, 1 Oct 2021 17:28:00 +0800 Subject: [PATCH] split the base images in order to prevent recompile the base part --- .dockerignore | 1 - docker/alpine-base.dockerfile | 8 ++++++++ docker/debian-base.dockerfile | 11 +++++++++++ dockerfile | 13 ++----------- dockerfile-alpine | 10 ++-------- package.json | 2 ++ 6 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 docker/alpine-base.dockerfile create mode 100644 docker/debian-base.dockerfile diff --git a/.dockerignore b/.dockerignore index 3d92084d7..539e93280 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,7 +19,6 @@ README.md .eslint* .stylelint* /.github -package-lock.json yarn.lock app.json CODE_OF_CONDUCT.md diff --git a/docker/alpine-base.dockerfile b/docker/alpine-base.dockerfile new file mode 100644 index 000000000..922fd2527 --- /dev/null +++ b/docker/alpine-base.dockerfile @@ -0,0 +1,8 @@ +# DON'T UPDATE TO alpine3.13, 1.14, see #41. +FROM node:14-alpine3.12 +WORKDIR /app + +# Install apprise, iputils for non-root ping, setpriv +RUN apk add --no-cache iputils setpriv dumb-init python3 py3-cryptography py3-pip py3-six py3-yaml py3-click py3-markdown py3-requests py3-requests-oauthlib && \ + pip3 --no-cache-dir install apprise && \ + rm -rf /root/.cache diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile new file mode 100644 index 000000000..e8737c7ce --- /dev/null +++ b/docker/debian-base.dockerfile @@ -0,0 +1,11 @@ +# DON'T UPDATE TO node:14-bullseye-slim, see #372. +# If the image changed, the second stage image should be changed too +FROM node:14-buster-slim +WORKDIR /app + +# Install Apprise, add sqlite3 cli for debugging in the future, iputils-ping for ping, util-linux for setpriv +RUN apt update && \ + apt --yes install python3 python3-pip python3-cryptography python3-six python3-yaml python3-click python3-markdown python3-requests python3-requests-oauthlib \ + sqlite3 iputils-ping util-linux dumb-init && \ + pip3 --no-cache-dir install apprise && \ + rm -rf /var/lib/apt/lists/* diff --git a/dockerfile b/dockerfile index e0616ba26..cabe8a073 100644 --- a/dockerfile +++ b/dockerfile @@ -1,6 +1,4 @@ -# DON'T UPDATE TO node:14-bullseye-slim, see #372. -# If the image changed, the second stage image should be changed too -FROM node:14-buster-slim AS build +FROM louislam/uptime-kuma:base-debian AS build WORKDIR /app COPY . . @@ -10,16 +8,9 @@ RUN npm install --legacy-peer-deps && \ chmod +x /app/extra/entrypoint.sh -FROM node:14-buster-slim AS release +FROM louislam/uptime-kuma:base-debian AS release WORKDIR /app -# Install Apprise, add sqlite3 cli for debugging in the future, iputils-ping for ping, util-linux for setpriv -RUN apt update && \ - apt --yes install python3 python3-pip python3-cryptography python3-six python3-yaml python3-click python3-markdown python3-requests python3-requests-oauthlib \ - sqlite3 iputils-ping util-linux dumb-init && \ - pip3 --no-cache-dir install apprise && \ - rm -rf /var/lib/apt/lists/* - # Copy app files from build layer COPY --from=build /app /app diff --git a/dockerfile-alpine b/dockerfile-alpine index 07ae30798..178afcabb 100644 --- a/dockerfile-alpine +++ b/dockerfile-alpine @@ -1,5 +1,4 @@ -# DON'T UPDATE TO alpine3.13, 1.14, see #41. -FROM node:14-alpine3.12 AS build +FROM louislam/uptime-kuma:base-alpine AS build WORKDIR /app COPY . . @@ -9,14 +8,9 @@ RUN npm install --legacy-peer-deps && \ chmod +x /app/extra/entrypoint.sh -FROM node:14-alpine3.12 AS release +FROM louislam/uptime-kuma:base-alpine AS release WORKDIR /app -# Install apprise, iputils for non-root ping, setpriv -RUN apk add --no-cache iputils setpriv dumb-init python3 py3-cryptography py3-pip py3-six py3-yaml py3-click py3-markdown py3-requests py3-requests-oauthlib && \ - pip3 --no-cache-dir install apprise && \ - rm -rf /root/.cache - # Copy app files from build layer COPY --from=build /app /app diff --git a/package.json b/package.json index 7828b9dc9..17bfe975c 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ "tsc": "tsc", "vite-preview-dist": "vite preview --host", "build-docker": "npm run build-docker-debian && npm run build-docker-alpine", + "build-docker-alpine-base": "docker buildx build -f docker/alpine-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-alpine . --push", + "build-docker-debian-base": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-debian . --push", "build-docker-alpine": "docker buildx build -f dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.7.3-alpine --target release . --push", "build-docker-debian": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.7.3 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.7.3-debian --target release . --push", "build-docker-nightly": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push",