diff --git a/Dockerfile b/Dockerfile index 4fe4519..cdb9f47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,34 @@ from golang:1.25-alpine as builder + env CGO_ENABLED=1 +env GOCACHE=/go/cache +env GOMODCACHE=/go/mod arg TAG='v1.16.1-alpha' workdir /app -run apk add git gcc musl-dev -run git clone -b ${TAG} https://tangled.org/@tangled.org/core . + +run --mount=type=cache,target=/var/cache/apk,sharing=locked \ + apk add --update-cache git gcc musl-dev + +run git clone -b ${TAG} https://tangled.org/tangled.org/core . + +run --mount=type=cache,target=/go/cache \ + --mount=type=cache,target=/go/mod \ + go mod download + from builder as build-knot -run go build -o /usr/bin/knot -ldflags '-s -w -extldflags "-static"' ./cmd/knot +run --mount=type=cache,target=/go/cache \ + --mount=type=cache,target=/go/mod \ + go build -o /usr/bin/knot -ldflags '-s -w -extldflags "-static"' ./cmd/knot + from builder as build-spindle -run go build -o /usr/bin/spindle ./cmd/spindle +run --mount=type=cache,target=/go/cache \ + --mount=type=cache,target=/go/mod \ + go build -o /usr/bin/spindle ./cmd/spindle + from alpine:latest as knot env KNOT_REPO_SCAN_PATH=/home/git/repositories @@ -31,7 +48,8 @@ arg GID=1000 copy rootfs / run chmod 755 /etc run chmod -R 755 /etc/s6-overlay -run apk add shadow s6-overlay execline openssl openssh git curl bash +run --mount=type=cache,target=/var/cache/apk,sharing=locked \ + apk add --update-cache shadow s6-overlay execline openssl openssh git curl bash run groupadd -g $GID -f git run useradd -l -u $UID -g $GID -d /home/git git run openssl rand -hex 16 | passwd --stdin git @@ -43,6 +61,7 @@ healthcheck --interval=60s --timeout=30s --start-period=5s --retries=3 \ cmd curl -f http://localhost:5555 || exit 1 entrypoint ["/init"] + from alpine:edge as spindle expose 6555 @@ -56,7 +75,9 @@ label org.opencontainers.image.licenses="MIT" arg UID=1000 arg GID=1000 -run apk add curl bash git +run --mount=type=cache,target=/var/cache/apk,sharing=locked \ + apk add --update-cache shadow git curl bash e2fsprogs iproute2 qemu-system-x86_64 slirp4netns util-linux + run adduser --system --uid $UID spindle run addgroup --system --gid $UID spindle run mkdir -p /app && chown -R spindle:spindle /app