From 2b5fb89434b16784a52b31c426bb55daaf277a31 Mon Sep 17 00:00:00 2001 From: Albert Le Batteux Date: Mon, 23 Jan 2023 16:38:11 +0000 Subject: [PATCH] chore(ci): dockerized :whale: --- .github/workflows/docker.yml | 39 ++++++++++++++++++++++++++++++++++++ Dockerfile | 14 +++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..cfabc5e --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,39 @@ +name: docker + +on: + push: + branches: + - 'master' + tags: + - 'v*' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest + type=semver,pattern=v{{version}} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4c328a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.19-alpine AS builder + +COPY . /app + +WORKDIR /app + +RUN go build -o cosmos-exporter + + +FROM alpine + +COPY --from=builder /app/cosmos-exporter /usr/local/bin/cosmos-exporter + +ENTRYPOINT [ "/usr/local/bin/cosmos-exporter" ]