feat: refactored Dockerfile (#1375)
- Removed VIKUNJA_VERSION and custom git checkout, because it is not found in the repository. So it is not used anywhere. - Optimized runner commands order - Removed run.sh (it is not needed in fact) Co-authored-by: Yurii Vlasov <yv@itsvit.org> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1375 Co-authored-by: Yurii Vlasov <yuriy@vlasov.pro> Co-committed-by: Yurii Vlasov <yuriy@vlasov.pro>
This commit is contained in:
parent
88dd544fc9
commit
522bf7d2fc
56
Dockerfile
56
Dockerfile
@ -1,51 +1,39 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
# ┬─┐┬ ┐o┬ ┬─┐
|
||||||
|
# │─││ │││ │ │
|
||||||
|
# ┘─┘┘─┘┘┘─┘┘─┘
|
||||||
|
|
||||||
##############
|
FROM techknowlogick/xgo:go-1.19.2 AS builder
|
||||||
# Build stage
|
|
||||||
FROM --platform=$BUILDPLATFORM techknowlogick/xgo:go-1.19.2 AS build-env
|
|
||||||
|
|
||||||
RUN \
|
RUN go install github.com/magefile/mage@latest && \
|
||||||
go install github.com/magefile/mage@latest && \
|
mv /go/bin/mage /usr/local/go/bin
|
||||||
mv /go/bin/mage /usr/local/go/bin
|
|
||||||
|
|
||||||
ARG VIKUNJA_VERSION
|
|
||||||
|
|
||||||
# Setup repo
|
|
||||||
COPY . /go/src/code.vikunja.io/api
|
|
||||||
WORKDIR /go/src/code.vikunja.io/api
|
WORKDIR /go/src/code.vikunja.io/api
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
ARG TARGETOS TARGETARCH TARGETVARIANT
|
ARG TARGETOS TARGETARCH TARGETVARIANT
|
||||||
# Checkout version if set
|
|
||||||
RUN if [ -n "${VIKUNJA_VERSION}" ]; then git checkout "${VIKUNJA_VERSION}"; fi && \
|
|
||||||
mage build:clean && \
|
|
||||||
mage release:xgo $TARGETOS/$TARGETARCH/$TARGETVARIANT
|
|
||||||
|
|
||||||
###################
|
RUN mage build:clean && \
|
||||||
|
mage release:xgo "${TARGETOS}/${TARGETARCH}/${TARGETVARIANT}"
|
||||||
|
|
||||||
|
# ┬─┐┬ ┐┌┐┐┌┐┐┬─┐┬─┐
|
||||||
|
# │┬┘│ │││││││├─ │┬┘
|
||||||
|
# ┘└┘┘─┘┘└┘┘└┘┴─┘┘└┘
|
||||||
|
|
||||||
# The actual image
|
# The actual image
|
||||||
# Note: I wanted to use the scratch image here, but unfortunatly the go-sqlite bindings require cgo and
|
# Note: I wanted to use the scratch image here, but unfortunatly the go-sqlite bindings require cgo and
|
||||||
# because of this, the container would not start when I compiled the image without cgo.
|
# because of this, the container would not start when I compiled the image without cgo.
|
||||||
FROM alpine:3.16
|
FROM alpine:3.16 AS runner
|
||||||
LABEL maintainer="maintainers@vikunja.io"
|
LABEL maintainer="maintainers@vikunja.io"
|
||||||
|
WORKDIR /app/vikunja
|
||||||
|
ENTRYPOINT [ "/sbin/tini", "-g", "--", "/entrypoint.sh" ]
|
||||||
|
|
||||||
WORKDIR /app/vikunja/
|
|
||||||
COPY --from=build-env /build/vikunja-* vikunja
|
|
||||||
ENV VIKUNJA_SERVICE_ROOTPATH=/app/vikunja/
|
ENV VIKUNJA_SERVICE_ROOTPATH=/app/vikunja/
|
||||||
|
|
||||||
# Dynamic permission changing stuff
|
|
||||||
ENV PUID 1000
|
ENV PUID 1000
|
||||||
ENV PGID 1000
|
ENV PGID 1000
|
||||||
RUN apk --no-cache add shadow && \
|
|
||||||
addgroup -g ${PGID} vikunja && \
|
|
||||||
adduser -s /bin/sh -D -G vikunja -u ${PUID} vikunja -h /app/vikunja -H && \
|
|
||||||
chown vikunja -R /app/vikunja
|
|
||||||
COPY run.sh /run.sh
|
|
||||||
|
|
||||||
# Add time zone data
|
RUN apk --update --no-cache add tzdata tini
|
||||||
RUN apk --no-cache add tzdata
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod 0755 /entrypoint.sh && mkdir files
|
||||||
|
|
||||||
# Files permissions
|
COPY --from=builder /build/vikunja-* vikunja
|
||||||
RUN mkdir /app/vikunja/files && \
|
|
||||||
chown -R vikunja /app/vikunja/files
|
|
||||||
VOLUME /app/vikunja/files
|
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
|
||||||
EXPOSE 3456
|
|
||||||
|
15
docker/entrypoint.sh
Normal file
15
docker/entrypoint.sh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -n "$PUID" ] && [ "$PUID" -ne 0 ] && \
|
||||||
|
[ -n "$PGID" ] && [ "$PGID" -ne 0 ] ; then
|
||||||
|
echo "info: creating the new user vikunja with $PUID:$PGID"
|
||||||
|
addgroup -g "$PGID" vikunja
|
||||||
|
adduser -s /bin/sh -D -G vikunja -u "$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…
x
Reference in New Issue
Block a user