Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(ci): multi-stage docker builds #76

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions ci.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
# build app
FROM --platform=$BUILDPLATFORM golang:1.20-alpine3.19 AS app-builder

ARG VERSION=dev
ARG REVISION=dev
ARG BUILDTIME
ARG TARGETOS TARGETARCH

RUN apk add --no-cache git tzdata
# build base
FROM --platform=$BUILDPLATFORM golang:1.20-alpine3.19 AS app-base

ENV SERVICE=seasonpackarr

WORKDIR /src
ARG VERSION=dev \
REVISION=dev \
BUILDTIME \
TARGETOS TARGETARCH

# Cache Go modules
COPY go.mod go.sum ./
RUN go mod download

COPY . ./

# build seasonpackarr
FROM --platform=$BUILDPLATFORM app-base AS seasonpackarr

RUN --mount=target=. \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${REVISION} -X main.date=${BUILDTIME}" -o /out/bin/seasonpackarr cmd/seasonpackarr/main.go

# build runner
FROM alpine:latest as RUNNER
RUN apk add --no-cache ca-certificates curl tzdata jq

LABEL org.opencontainers.image.source = "https://github.com/nuxencs/seasonpackarr"
LABEL org.opencontainers.image.licenses = "GPL-2.0-or-later"
LABEL org.opencontainers.image.base.name = "alpine:latest"
LABEL org.opencontainers.image.source = "https://github.com/nuxencs/seasonpackarr" \
org.opencontainers.image.licenses = "GPL-2.0-or-later" \
org.opencontainers.image.base.name = "alpine:latest"

ENV HOME="/config" \
XDG_CONFIG_HOME="/config" \
XDG_DATA_HOME="/config"

RUN apk add --no-cache ca-certificates curl tzdata jq

WORKDIR /app
VOLUME /config
EXPOSE 42069

COPY --link --from=app-builder /out/bin/seasonpackarr /usr/bin/


ENTRYPOINT ["/usr/bin/seasonpackarr", "start", "--config", "/config"]

COPY --link --from=seasonpackarr /out/bin/seasonpackarr /usr/bin/