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" ]