diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5a07718 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,39 @@ +name: docker + +on: + push: + branches: + - "main" + 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..05ca32e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.20-alpine AS builder + +COPY . /app + +WORKDIR /app + +RUN go build -o gnofaucet ./cmd + + +FROM alpine + +COPY --from=builder /app/gnofaucet /usr/local/bin/gnofaucet + +ENTRYPOINT [ "/usr/local/bin/gnofaucet" ]