add Docker container
This commit is contained in:
parent
90632daa10
commit
959227b0af
2 changed files with 45 additions and 2 deletions
|
|
@ -26,7 +26,39 @@ build-application-binary:
|
|||
parallel: !reference [.parallel,parallel]
|
||||
image: public.ecr.aws/docker/library/golang:1.21.4-bookworm
|
||||
script:
|
||||
- go build -o rss2gotify-${GOOS}-${GOARCH} ./
|
||||
- go build -o gotifyWebhookForwarder-${GOOS}-${GOARCH} ./
|
||||
artifacts:
|
||||
paths:
|
||||
- rss2gotify-${GOOS}-${GOARCH}
|
||||
- gotifyWebhookForwarder-${GOOS}-${GOARCH}
|
||||
|
||||
|
||||
Docker:
|
||||
# Use the official docker image.
|
||||
image: gitlab.jonasled.de/jonasled/buildx-docker:latest
|
||||
stage: build
|
||||
needs: []
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- docker context create build
|
||||
- docker buildx create build --use
|
||||
- docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
- apk add jq
|
||||
# Default branch leaves tagempty (= latest tag)
|
||||
# All other branches are tagged with the escaped branch name (commit ref slug)
|
||||
script:
|
||||
- |
|
||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||
tag="latest"
|
||||
else
|
||||
tag="$CI_COMMIT_REF_SLUG"
|
||||
fi
|
||||
- docker buildx build --platform linux/arm64,linux/amd64 --push --provenance false --tag "$CI_REGISTRY_IMAGE:${tag}" .
|
||||
- export IMAGE_HASH=$(docker buildx imagetools inspect "$CI_REGISTRY_IMAGE:${tag}" --format "{{json .Manifest}}" | jq .digest)
|
||||
- "echo \"Image Hash: $IMAGE_HASH\""
|
||||
- echo "$IMAGE_HASH" >> image-hash.txt
|
||||
artifacts:
|
||||
paths:
|
||||
- image-hash.txt
|
||||
|
||||
|
|
|
|||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
FROM public.ecr.aws/docker/library/golang:1.21.4-bookworm AS build
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY *.go ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /gotifyWebhookForwarder
|
||||
FROM alpine:3.18.4
|
||||
RUN apk add --no-cache ca-certificates
|
||||
COPY --from=build /gotifyWebhookForwarder /gotifyWebhookForwarder
|
||||
ENTRYPOINT ["/gotifyWebhookForwarder"]
|
||||
EXPOSE 3333
|
||||
Loading…
Add table
Add a link
Reference in a new issue