From 6f445cd7ee530817c521d498c0d353e000d583de Mon Sep 17 00:00:00 2001 From: Tom Neuber Date: Fri, 16 Feb 2024 23:01:12 +0100 Subject: [PATCH] Add Dockerfile & build pipeline --- .drone.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 25 +++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 Dockerfile diff --git a/.drone.yml b/.drone.yml index 843930a..38e5db5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,3 +17,57 @@ steps: when: event: - push +- name: docker + image: thegeeklab/drone-docker-buildx + privileged: true + settings: + registry: git.ar21.de + username: + from_secret: REGISTRY_USER + password: + from_secret: REGISTRY_PASS + repo: git.ar21.de/yolokube/grafana-backuper + tags: + - latest + - ${DRONE_BUILD_NUMBER} + platforms: + - linux/arm64 + - linux/amd64 + when: + branch: + - main + event: + - push + depends_on: + - gofmt + - vuln-check +- name: docker-build + image: thegeeklab/drone-docker-buildx + privileged: true + settings: + registry: git.ar21.de + username: + from_secret: REGISTRY_USER + password: + from_secret: REGISTRY_PASS + repo: git.ar21.de/yolokube/grafana-backuper + tags: + - latest + - ${DRONE_BUILD_NUMBER} + platforms: + - linux/arm64 + - linux/amd64 + dry_run: true + when: + branch: + exclude: + - main + event: + - push + depends_on: + - gofmt + - vuln-check +when: + event: + exclude: + - pull_request diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..490977d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.22.0-bookworm AS build + +# Create build workspace folder +WORKDIR /workspace +ADD . /workspace + +# Install updates and build tools +RUN apt-get update --yes && \ + apt-get install --yes build-essential + +# Build the actual binary +RUN CGO_ENABLED=0 go build -o grafana-backuper main.go + +# -- -- -- -- -- -- + +# Set up image to run the tool +FROM alpine + +# Create main app folder to run from +WORKDIR /app + +# Copy built binary from build image +COPY --from=build /workspace/grafana-backuper /app + +ENTRYPOINT ["/app/grafana-backuper"]