From fcba6069a292675dd105c991803ba74d68e7efc8 Mon Sep 17 00:00:00 2001 From: Harsh Singhvi Date: Fri, 17 Nov 2023 00:48:31 +0530 Subject: [PATCH] Setup GH Actions --- .github/workflows/docker-image.yml | 31 ++++++++++++++++++++++++++++++ Dockerfile | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..01c6fb3 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,31 @@ +name: ci + +on: + push: + branches: + - "main" + - "master" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to ghcr + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GH_TOKEN}} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/harshsinghvi/golang-postgres-kubernetes:latest diff --git a/Dockerfile b/Dockerfile index 26f5619..efca79e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ # STEP 1 build executable binary ############################ FROM golang:alpine AS builder +LABEL org.opencontainers.image.source="https://github.com/harshsinghvi/golang-postgres-kubernetes" # Install git. # Git is required for fetching the dependencies. RUN apk update && apk add --no-cache 'git=~2' @@ -22,6 +23,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/main . # STEP 2 build a small image ############################ FROM alpine +LABEL org.opencontainers.image.source="https://github.com/harshsinghvi/golang-postgres-kubernetes" WORKDIR /