diff --git a/docker/Dockerfile b/docker/Dockerfile index bbed0fb58..ec9527e75 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -58,21 +58,29 @@ LABEL org.opencontainers.image.documentation=https://gotify.net/ LABEL org.opencontainers.image.source=https://github.com/gotify/server # Build-time configurables -ARG GOTIFY_SERVER_EXPOSE=80 +ARG GOTIFY_SERVER_EXPOSE=8080 ENV GOTIFY_SERVER_PORT=$GOTIFY_SERVER_EXPOSE +ENV GOTIFY_USER="" +ENV GOTIFY_GROUP="" WORKDIR /app RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -yq --no-install-recommends \ tzdata \ curl \ - ca-certificates && \ + ca-certificates \ + gosu && \ rm -rf /var/lib/apt/lists/* HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD curl --fail http://localhost:$GOTIFY_SERVER_PORT/health || exit 1 EXPOSE $GOTIFY_SERVER_EXPOSE COPY --from=builder /target / +COPY docker/entrypoint.sh /app/entrypoint.sh + +RUN chmod +x /app/entrypoint.sh && \ + mkdir -p /app/data && \ + chmod 0750 /app/data -ENTRYPOINT ["./gotify-app"] +ENTRYPOINT ["./entrypoint.sh"] CMD ["serve"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 000000000..6592802db --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +if [ -n "${GOTIFY_USER:-}" ] && [ "$(id -u)" = "0" ]; then + mkdir -p data + chown -R "$GOTIFY_USER:${GOTIFY_GROUP:-$GOTIFY_USER}" data + exec gosu "$GOTIFY_USER:${GOTIFY_GROUP:-$GOTIFY_USER}" ./gotify-app "$@" +fi + +exec ./gotify-app "$@" diff --git a/gotify-server.env.example b/gotify-server.env.example index 2343a6499..c44f5a421 100644 --- a/gotify-server.env.example +++ b/gotify-server.env.example @@ -50,7 +50,7 @@ # Port the HTTP server listens on. # Type: number -# GOTIFY_SERVER_PORT=80 +# GOTIFY_SERVER_PORT=8080 # Enable the HTTPS listener. Requires either CERTFILE+CERTKEY or LETSENCRYPT_ENABLED=true. # Type: boolean