From 3956b2d944e459db791bd3ce58da71d6e5aec1d2 Mon Sep 17 00:00:00 2001 From: Suika <2320837+Suika@users.noreply.github.com> Date: Thu, 3 Oct 2019 02:09:56 +0200 Subject: [PATCH 1/2] Alpine docker container Build everything in the staged container and only copy the complete product to the final container. Also reduced the size of the container threefold. Created `data/{config,db,images,TEMP}` to make volumes possible for ease of use with docker and persistence of configurations. `config.json` symlinks to `data/config/config.json` since I don'T know how to call for the config in different path --- docker/alpine/Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 docker/alpine/Dockerfile diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile new file mode 100644 index 00000000..3456d6a5 --- /dev/null +++ b/docker/alpine/Dockerfile @@ -0,0 +1,22 @@ +FROM node:alpine +RUN apk add python build-base +COPY . /build +WORKDIR /build +RUN set -x && npm install --unsafe-perm && npm run build-release && \ + cd /build/release && npm install --unsafe-perm +RUN mkdir -p /build/release/data/config && \ + mkdir -p /build/release/data/db && \ + mkdir -p /build/release/data/image && \ + mkdir -p /build/release/data/TEMP && \ + cd /build/release && node backend/server.js && \ + sed -i 's/demo/data/g' config.json && sed -i 's@sqlite\.db@data/db/sqlite\.db@' config.json && \ + mv /build/release/config.json /build/release/data/config/config.json + +FROM node:alpine +WORKDIR /app +ENTRYPOINT ["npm", "start"] +EXPOSE 80 +ENV NODE_ENV=production +COPY --from=0 /build/release /app +RUN ln -s /app/data/config/config.json config.json +VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/TEMP"] From 9c6a7c97e3f86afc4bd280b5c6d824fa0aa6b0ad Mon Sep 17 00:00:00 2001 From: Suika <2320837+Suika@users.noreply.github.com> Date: Thu, 3 Oct 2019 02:56:20 +0200 Subject: [PATCH 2/2] Add healthcheck --- docker/alpine/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index 3456d6a5..dc6bebe8 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -20,3 +20,6 @@ ENV NODE_ENV=production COPY --from=0 /build/release /app RUN ln -s /app/data/config/config.json config.json VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/TEMP"] +HEALTHCHECK --interval=15s --timeout=5s --retries=4 --start-period=30s \ + CMD wget --quiet --tries=1 --no-check-certificate --spider \ + http://localhost:80 || exit 1