From ea1cae89bc3e71394e667503f3e7a92279af07d8 Mon Sep 17 00:00:00 2001 From: Mikhail Nacharov Date: Tue, 14 May 2024 15:49:02 +0400 Subject: [PATCH] ci: build image --- .github/workflows/deploy.yml | 40 ++++++++++++++++++++++++++++++++++++ Dockerfile | 14 +++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c0d8053 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,40 @@ +name: Build Docker Image + +on: + push: + branches: + - main + tags: + - "v*" + +jobs: + build-images: + runs-on: ubuntu-latest + outputs: + author-name: ${{ steps.author-name.outputs.author-name }} + author-email: ${{ steps.author-email.outputs.author-email }} + tag: ${{ steps.tag.outputs.tag }} + steps: + - uses: actions/checkout@v4.1.4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5.5.1 + with: + images: europe-west4-docker.pkg.dev/iaas-383414/iaas/grafana-datasource-oauth-proxy + tags: | + type=ref,event=tag + type=sha,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + flavor: | + latest=false + - name: Login to GAR + uses: docker/login-action@v3.1.0 + with: + registry: europe-west4-docker.pkg.dev + username: _json_key + password: "${{ secrets.GOOGLE_ARTIFACTREGISTRY_CREDENTIALS }}" + - name: Build and push + uses: docker/build-push-action@v5.3.0 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c52d61f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.22.3-bookworm as build + +WORKDIR /go/src/grafana-datasource-oauth-proxy +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . . +RUN CGO_ENABLED=0 go build -v -o /go/bin/grafana-datasource-oauth-proxy ./... + +FROM gcr.io/distroless/static-debian12:latest + +COPY --from=build /go/bin/grafana-datasource-oauth-proxy / + +CMD ["/grafana-datasource-oauth-proxy"]