From 5e38c7d730b8dda8651d1ddf2ab27d22741a2897 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Tue, 10 Jun 2025 09:00:57 -0400 Subject: [PATCH 1/2] feat: build with docker buildx bake Signed-off-by: Xe Iaso --- .dockerignore | 25 +++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ docker-bake.hcl | 27 +++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-bake.hcl diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2418994 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +.env +*.deb +*.rpm + +# Additional package locks +pnpm-lock.yaml +yarn.lock + +# Go binaries and test artifacts +main +*.test + +node_modules + +# MacOS +.DS_store + +# Intellij +.idea + +# how does this get here +doc/VERSION + +web/static/js/* +!web/static/js/.gitignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2368eba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +ARG ALPINE_VERSION=edge +FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS build + +ARG TARGETOS +ARG TARGETARCH +ARG COMPONENT=anubis +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 + +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/${COMPONENT} -ldflags "-s -w -extldflags -static -X github.com/TecharoHQ/anubis.Version=${VERSION}" ./cmd/${COMPONENT} + +FROM alpine:${ALPINE_VERSION} AS run +WORKDIR /app + +RUN apk -U add ca-certificates mailcap + +COPY --from=build /app/bin/anubis /app/bin/anubis + +CMD ["/app/bin/anubis"] + +LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis" \ No newline at end of file diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..005f818 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,27 @@ +variable "ALPINE_VERSION" { default = "3.22" } +variable "GITHUB_SHA" { default = "devel" } + +group "default" { + targets = [ + "anubis", + ] +} + +target "anubis" { + args = { + ALPINE_VERSION = "3.22" + } + context = "." + dockerfile = "./Dockerfile" + platforms = [ + "linux/amd64", + "linux/arm64", + "linux/arm/v7", + "linux/ppc64le", + "linux/riscv64", + ] + pull = true + tags = [ + "ghcr.io/techarohq/anubis:${GITHUB_SHA}" + ] +} \ No newline at end of file From 50e48df9936d0324475921b0192517364f26a5be Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Fri, 13 Jun 2025 15:24:42 -0400 Subject: [PATCH 2/2] fix(Dockerfile): add HEALTHCHECK Signed-off-by: Xe Iaso --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 2368eba..e7ec7d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,5 +25,6 @@ RUN apk -U add ca-certificates mailcap COPY --from=build /app/bin/anubis /app/bin/anubis CMD ["/app/bin/anubis"] +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/bin/anubis", "--healthcheck" ] LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis" \ No newline at end of file