Skip to content

Commit 3be11e6

Browse files
committed
ci: update Container streamlining
Use scratch as base instead of alpine Update LABELS and build args
1 parent 7b5136c commit 3be11e6

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ jobs:
4242
push: true
4343
sbom: true
4444
build-args: |
45-
GITLAB_SYNC_VERSION=${{ github.ref_name }}
45+
VERSION=${{ github.ref_name }}
46+
REVISION=${{ github.sha }}
47+
BUILD_DATE=${{ github.event.head_commit.timestamp }}
4648
tags: |
4749
ghcr.io/${{ env.REPO_NAME }}:${{ github.ref_name }}
4850
ghcr.io/${{ env.REPO_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }}

Containerfile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
FROM docker.io/golang:1.23.7-alpine AS build
1+
FROM docker.io/golang:1.24.2-alpine AS build
22

3-
ARG GITLAB_SYNC_VERSION="dev"
3+
ARG VERSION="dev"
44

55
WORKDIR /app
66

77
COPY go.mod .
88
COPY ./cmd/ ./cmd/
9-
COPY ./mirroring/ ./mirroring/
10-
COPY ./utils/ ./utils/
9+
COPY ./internal/ ./internal/
10+
11+
ENV GO111MODULE=on \
12+
CGO_ENABLED=0
1113

1214
RUN go mod tidy && \
13-
go build -ldflags "-X 'main.version=${GITLAB_SYNC_VERSION}'" -o /app/bin/gitlab-sync ./cmd/main.go
15+
go build -ldflags "-X 'main.version=${VERSION}'" -o /app/bin/gitlab-sync ./cmd/main.go
16+
17+
FROM scratch
1418

15-
FROM docker.io/alpine:latest
19+
ARG BUILD_DATE="1970-01-01T00:00:00Z" \
20+
VERSION="dev" \
21+
REVISION="dev"
1622

17-
RUN adduser -u 1000 -D -S gitlab-sync
23+
LABEL org.opencontainers.image.title="gitlab-sync" \
24+
org.opencontainers.image.description="synchronize GitLab projects and groups between two GitLab instances" \
25+
org.opencontainers.image.source="${SOURCE}" \
26+
org.opencontainers.image.url="gitlab.com/boxboxjason/gitlab-sync" \
27+
org.opencontainers.image.created="${BUILD_DATE}" \
28+
org.opencontainers.image.revision="${REVISION}" \
29+
org.opencontainers.image.version="${VERSION}" \
30+
org.opencontainers.image.vendor="boxboxjason"
1831

19-
COPY --from=build --chown=gitlab-sync --chmod=550 /app/bin/gitlab-sync /usr/local/bin/gitlab-sync
32+
COPY --from=build /app/bin/gitlab-sync /usr/local/bin/gitlab-sync
2033

2134
ENTRYPOINT [ "/usr/local/bin/gitlab-sync" ]

0 commit comments

Comments
 (0)