ci: refactor dockerfile to build with many speed

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-07-18 23:52:58 +00:00
parent 89b6af05a3
commit 153da4f5ac
3 changed files with 52 additions and 16 deletions

View File

@@ -1,20 +1,22 @@
ARG ALPINE_VERSION=edge
FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS build
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=devel-docker
RUN apk -U add go nodejs git build-base git npm bash zstd brotli gzip
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/root/go go mod download
COPY package.json package-lock.json ./
RUN npm ci
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=devel-docker
COPY . .
RUN --mount=type=cache,target=/root/.cache npm ci && npm run assets
RUN --mount=type=cache,target=/root/.cache GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GOARM=7 go build -gcflags "all=-N -l" -o /app/bin/osiris -ldflags "-s -w -extldflags -static -X github.com/TecharoHQ/anubis.Version=${VERSION}" ./cmd/osiris
RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/root/go GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GOARM=7 go build -gcflags "all=-N -l" -o /app/bin/osiris -ldflags "-s -w -extldflags -static -X github.com/TecharoHQ/anubis.Version=${VERSION}" ./cmd/osiris
FROM alpine:${ALPINE_VERSION} AS run
WORKDIR /app
@@ -23,7 +25,6 @@ RUN apk -U add ca-certificates mailcap
COPY --from=build /app/bin/osiris /app/bin/osiris
CMD ["/app/bin/anubis"]
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/bin/anubis", "--healthcheck" ]
CMD ["/app/bin/osiris"]
LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis"