From: Adam Dullage Date: Fri, 19 Apr 2024 11:58:39 +0000 (+0100) Subject: Added FLATNOTES_PORT env var X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=52bca5919d0ad0d8f175c4ba9abc22f0be9a6793;p=flatnotes.git Added FLATNOTES_PORT env var --- diff --git a/.dockerignore b/.dockerignore index 2740fa7..ef36c28 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,13 +2,14 @@ ** # Include the following +!.htmlnanorc !LICENSE !Pipfile !Pipfile.lock -!package.json -!package-lock.json !client/** -!server/** !entrypoint.sh -!.htmlnanorc +!healthcheck.sh +!package-lock.json +!package.json +!server/** !vite.config.js diff --git a/Dockerfile b/Dockerfile index 84a54cb..c3447eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ ARG BUILD_DIR ENV PUID=1000 ENV PGID=1000 ENV EXEC_TOOL=gosu +ENV FLATNOTES_PORT=8080 ENV APP_PATH=/app ENV FLATNOTES_PATH=/data @@ -45,10 +46,11 @@ RUN pipenv install --deploy --ignore-pipfile --system && \ COPY server ./server COPY --from=build ${BUILD_DIR}/client/dist ./client/dist +COPY entrypoint.sh healthcheck.sh / +RUN chmod +x /entrypoint.sh /healthcheck.sh + VOLUME /data -EXPOSE 8080/tcp -HEALTHCHECK --interval=60s --timeout=10s CMD curl -f http://localhost:8080/health || exit 1 +EXPOSE ${FLATNOTES_PORT}/tcp +HEALTHCHECK --interval=60s --timeout=10s CMD /healthcheck.sh -COPY entrypoint.sh / -RUN chmod +x /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/entrypoint.sh b/entrypoint.sh index d9fbf3c..737990c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,7 +22,7 @@ flatnotes_command="python -m \ main:app \ --app-dir server \ --host 0.0.0.0 \ - --port 8080 \ + --port ${FLATNOTES_PORT} \ --proxy-headers \ --forwarded-allow-ips '*'" @@ -32,7 +32,7 @@ if [ `id -u` -eq 0 ] && [ `id -g` -eq 0 ]; then echo Starting flatnotes as user ${PUID}... exec ${EXEC_TOOL} ${PUID}:${PGID} ${flatnotes_command} - + else echo "A user was set by docker, skipping file permission changes." echo Starting flatnotes as user $(id -u)... diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100644 index 0000000..8d01824 --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +curl -f http://localhost:${FLATNOTES_PORT}/health || exit 1