Refactored Dockerfile #1375
17
Dockerfile
17
Dockerfile
|
@ -25,16 +25,15 @@ RUN mage build:clean && \
|
|||
# because of this, the container would not start when I compiled the image without cgo.
|
||||
FROM alpine:3.16 AS runner
|
||||
LABEL maintainer="maintainers@vikunja.io"
|
||||
WORKDIR /app/vikunja/
|
||||
WORKDIR /app/vikunja
|
||||
ENTRYPOINT [ "/sbin/tini", "-g", "--", "/entrypoint.sh" ]
|
||||
|
||||
ENTRYPOINT [ "/app/vikunja/vikunja" ]
|
||||
ENV VIKUNJA_SERVICE_ROOTPATH=/app/vikunja/
|
||||
ENV VIKUNJA_PUID 1000
|
||||
ENV VIKUNJA_PGID 1000
|
||||
|
||||
|
||||
RUN apk --update --no-cache add tzdata && \
|
||||
addgroup -g 1000 vikunja && \
|
||||
adduser -s /bin/sh -D -G vikunja -u 1000 vikunja -h /app/vikunja -H && \
|
||||
mkdir files && \
|
||||
chown vikunja:vikunja files
|
||||
RUN apk --update --no-cache add tzdata tini
|
||||
konrad
commented
The uid and gid of the Vikunja user has to be adjustable at runtime to avoid permission problems with the sqlite db (if used) or file uploads. That's what the script was used for. The uid and gid of the Vikunja user has to be adjustable at runtime to avoid permission problems with the sqlite db (if used) or file uploads. That's what the script was used for.
vlasov-y
commented
Done. I have created an entrypoint script back and run it using tini. Now user creation can be controlled with env variables, which are set to 1000:1000 by default, but can be overridden during the runtime Done. I have created an entrypoint script back and run it using [tini](https://github.com/krallin/tini). Now user creation can be controlled with env variables, which are set to 1000:1000 by default, but can be overridden during the runtime
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod 0755 /entrypoint.sh && mkdir files
|
||||
|
||||
COPY --from=builder --chown=vikunja:vikunja /build/vikunja-* vikunja
|
||||
USER vikunja
|
||||
COPY --from=builder /build/vikunja-* vikunja
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
if [ -n "$VIKUNJA_PUID" ] && [ "$VIKUNJA_PUID" -ne 0 ] && \
|
||||
[ -n "$VIKUNJA_PGID" ] && [ "$VIKUNJA_PGID" -ne 0 ] ; then
|
||||
echo "info: creating the new user vikunja with $VIKUNJA_PUID:$VIKUNJA_PGID"
|
||||
addgroup -g "$VIKUNJA_PGID" vikunja
|
||||
adduser -s /bin/sh -D -G vikunja -u "$VIKUNJA_PUID" vikunja -h /app/vikunja -H
|
||||
chown -R vikunja:vikunja ./
|
||||
su -pc /app/vikunja/vikunja - vikunja "$@"
|
||||
else
|
||||
echo "info: creation of non-root user is skipped"
|
||||
exec /app/vikunja/vikunja "$@"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Can you rename these to just
PUID
andPGID
? As documented here: https://vikunja.io/docs/install-backend/#setting-user-and-group-id-of-the-user-running-vikunjaOkay
Done, please check