From 83fc8c67dcc4501425a6a6dc6c6e7250989324b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wysoki=C5=84ski?= Date: Tue, 19 Jul 2022 04:48:31 +0000 Subject: [PATCH] feat(cicd): add two new pipelines responsible for pushing docker image to docker hub and Dockerfile (#7) Reviewed-on: https://gitea.dwysokinski.me/Kichiyaki/notificationarr/pulls/7 --- .dockerignore | 1 - .drone.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 23 +++++++++++++++++++++++ manifest.tmpl | 13 +++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 manifest.tmpl diff --git a/.dockerignore b/.dockerignore index 79352e6..4824967 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,5 +14,4 @@ build k8s internal/tools .commitlintrc.yml -additional_envs.sh skaffold.yaml diff --git a/.drone.yml b/.drone.yml index db86810..c59b0ab 100644 --- a/.drone.yml +++ b/.drone.yml @@ -53,3 +53,52 @@ trigger: - pull_request branch: - master + +--- +kind: pipeline +type: docker +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: + - name: publish + image: plugins/docker + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: kichiyaki/notificationarr + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: Dockerfile + +trigger: + event: + - tag +--- +kind: pipeline +type: docker +name: manifest + +steps: + - name: manifest + image: plugins/manifest + settings: + auto_tag: "true" + ignore_missing: "true" + spec: manifest.tmpl + username: + from_secret: docker_username + password: + from_secret: docker_password + +trigger: + event: + - tag + +depends_on: + - linux-amd64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..61ea7ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.18.4-alpine3.16 as builder + +WORKDIR /notificationarr + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN CGO_ENABLED=0 go build -trimpath -o notificationarr . + +######## Start a new stage from scratch ####### +FROM alpine:3.16 + +RUN apk --no-cache add ca-certificates + +COPY --from=builder /notificationarr/notificationarr /usr/bin/ + +EXPOSE 9234/tcp + +HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:9234/health || exit 1 + +CMD ["notificationarr"] diff --git a/manifest.tmpl b/manifest.tmpl new file mode 100644 index 0000000..f1b08e4 --- /dev/null +++ b/manifest.tmpl @@ -0,0 +1,13 @@ +image: kichiyaki/notificationarr:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - + image: kichiyaki/notificationarr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux