From 502173ee63a3e5bbf70d41b494db512c79325e05 Mon Sep 17 00:00:00 2001 From: Marketen Date: Sat, 7 Jun 2025 21:32:01 +0200 Subject: [PATCH] dockerfile and releaseyml --- .github/workflows/release.yml | 50 +++++++++++++++++++++++++++++++++++ Dockerfile | 27 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..49b6139 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release + +on: + workflow_dispatch: + inputs: + tag: + description: "Tag of the release (i.e. 0.1.0)" + required: true + +jobs: + push-to-ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - 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.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + file: Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ghcr.io/${{ github.repository_owner }}/validator-tracker:${{ github.event.inputs.tag }} + + gh-release: + runs-on: ubuntu-latest + needs: push-to-ghcr + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.inputs.tag }} + name: Release ${{ github.event.inputs.tag }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..967d1cc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:1.24-alpine AS builder + +WORKDIR /app + +# Install git for Go modules +RUN apk update && apk add --no-cache git + +# Cache dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the entire codebase +COPY . . + +# Build the binary +RUN go build -o validator-tracker ./cmd/main.go + +# Final image +FROM alpine:3.21 + +WORKDIR /app + +# Copy built binary +COPY --from=builder /app/validator-tracker . + +# Run the app +CMD ["./validator-tracker"]