Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Healthchecks: 127.0.0.1 statt localhost, konfigurierter Port statt 80, /api/health statt /api/config

Duarte Santos32c9a2380d72
diff --cc .github/workflows/docker-publish.yml
index b609db664,b65f7346c..ec6db7d77
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@@ -34,6 -29,13 +34,19 @@@ jobs
id: repo
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
+ - name: Set version metadata
+ id: version_meta
+ run: |
- echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
++ # On a release the ref is refs/tags/vX.Y.Z; on a main push it is a branch ref,
++ # which would otherwise label the image "refs/heads/main".
++ case "$GITHUB_REF" in
++ refs/tags/*) VERSION="${GITHUB_REF#refs/tags/}" ;;
++ *) VERSION="main-${GITHUB_SHA::7}" ;;
++ esac
++ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
+ echo "VCS_REF=${GITHUB_SHA}" >> $GITHUB_OUTPUT
+ echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
+
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
diff --cc api/Dockerfile
index ee69c8a71,0276fe981..e924c28b4
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@@ -1,8 -1,32 +1,32 @@@
FROM node:22-alpine
+
+ ARG VERSION=dev
+ ARG VCS_REF=dev
+ ARG BUILD_DATE=unknown
+
+ LABEL maintainer="Duarte Santos https://github.com/DuarteSantos8" \
+ org.opencontainers.image.title="opengym-api" \
+ org.opencontainers.image.description="Backend for Self-hosted gym & body-weight tracker — plan routines, log workouts (supersets & cardio too), track your weight and progress, passkey login. Your data, your server." \
+ org.opencontainers.image.source="https://github.com/DuarteSantos8/openGym" \
- org.opencontainers.image.url="http://ghcr.io/duartesantos8/opengym-api" \
- org.opencontainers.image.documentation="https://github.com/DuarteSantos8/openGym#" \
- org.opencontainers.image.licenses="AGPL-3.0 license" \
++ org.opencontainers.image.url="https://ghcr.io/duartesantos8/opengym-api" \
++ org.opencontainers.image.documentation="https://github.com/DuarteSantos8/openGym#readme" \
++ org.opencontainers.image.licenses="AGPL-3.0-or-later" \
+ org.opencontainers.image.version=$VERSION \
+ org.opencontainers.image.revision=$VCS_REF \
+ org.opencontainers.image.created=$BUILD_DATE
+
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install --omit=dev && npm cache clean --force
COPY server.js ./
+
ENV NODE_ENV=production
+ ENV PORT=3000
+
EXPOSE 3000
CMD ["node", "server.js"]
+
+ HEALTHCHECK --interval=5m \
+ --timeout=5s \
+ --retries=3 \
- CMD wget --spider -q http://localhost:${PORT}/api/config
++ CMD wget --spider -q "http://127.0.0.1:${PORT}/api/health" || exit 1
diff --cc web/Dockerfile
index ba216100d,96ed2d0be..1c2adf7ba
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@@ -15,12 -15,27 +15,36 @@@ COPY frontend/ .
RUN npm run build
FROM nginx:alpine
-
+ ARG VERSION=dev
+ ARG VCS_REF=dev
+ ARG BUILD_DATE=unknown
+
+ LABEL maintainer="Duarte Santos https://github.com/DuarteSantos8" \
+ org.opencontainers.image.title="opengym-web" \
+ org.opencontainers.image.description="Frontend for Self-hosted gym & body-weight tracker — plan routines, log workouts (supersets & cardio too), track your weight and progress, passkey login. Your data, your server." \
+ org.opencontainers.image.source="https://github.com/DuarteSantos8/openGym" \
- org.opencontainers.image.url="http://ghcr.io/duartesantos8/opengym-web" \
- org.opencontainers.image.documentation="https://github.com/DuarteSantos8/openGym#" \
- org.opencontainers.image.licenses="AGPL-3.0 license" \
++ org.opencontainers.image.url="https://ghcr.io/duartesantos8/opengym-web" \
++ org.opencontainers.image.documentation="https://github.com/DuarteSantos8/openGym#readme" \
++ org.opencontainers.image.licenses="AGPL-3.0-or-later" \
+ org.opencontainers.image.version=$VERSION \
+ org.opencontainers.image.revision=$VCS_REF \
+ org.opencontainers.image.created=$BUILD_DATE
+
-COPY web/nginx.conf /etc/nginx/conf.d/default.conf
+COPY web/nginx.conf.template /etc/nginx/templates/default.conf.template
COPY --from=build /app/dist /usr/share/nginx/html
# exercise media (img/gif) is mounted at runtime from the media volume
+# Set Default ENVs for nginx
+ENV NGINX_PORT=80
+ENV BACKEND=api
+ENV PORT=3000
+
++# Probe the port nginx was actually told to listen on (NGINX_PORT is configurable, so a
++# hardcoded http://localhost/ breaks on any instance that changed it), and address it as
++# 127.0.0.1: envsubst rewrites the conf after the image's IPv6 script, so nginx ends up
++# listening on IPv4 only while "localhost" resolves to ::1 first.
+ HEALTHCHECK --interval=5m \
+ --timeout=5s \
+ --retries=3 \
- CMD curl -fs http://localhost/
++ CMD wget --spider -q "http://127.0.0.1:${NGINX_PORT}/" || exit 1
++