diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index ded2f5d..743ca3b 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -67,6 +67,7 @@ jobs: go build -o gitpoll ./cmd/gitpoll - name: Semantic Release + id: semantic uses: cycjimmy/semantic-release-action@v4 env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -75,3 +76,24 @@ jobs: @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/github + + - name: Set up Docker Buildx + if: steps.semantic.outputs.new_release_published == 'true' + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: steps.semantic.outputs.new_release_published == 'true' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + if: steps.semantic.outputs.new_release_published == 'true' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + starpia/gitpoll:${{ steps.semantic.outputs.new_release_version }} + starpia/gitpoll:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a19c37b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Build stage +FROM golang:alpine AS builder +WORKDIR /app + +# Download dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the source code +COPY . . + +# Build the application +RUN CGO_ENABLED=0 GOOS=linux go build -o gitpoll ./cmd/gitpoll + +# Final stage +FROM alpine:latest + +# Install necessary runtime dependencies (git, bash, openssh) +RUN apk add --no-cache git bash openssh + +WORKDIR /app + +# Copy the binary from the builder stage +COPY --from=builder /app/gitpoll . + +# Ensure the binary is executable +RUN chmod +x ./gitpoll + +# Set the entrypoint +ENTRYPOINT ["./gitpoll"] diff --git a/README.md b/README.md index 6c75cd6..4ec5795 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Configuration is managed locally through a JSON file and an interactive TUI setu ### Running the Application +#### Option 1: Direct Execution 1. Download the latest pre-built binary from the GitHub Releases page, or build it yourself (`go build ./cmd/gitpoll`). 2. Run the executable: @@ -76,6 +77,19 @@ Configuration is managed locally through a JSON file and an interactive TUI setu 4. Follow the paginated on-screen prompts in the terminal to configure the repository URL, local directory, branch, execution command, and polling interval. You can leave fields blank to use the suggested defaults shown in brackets. 5. Review the summary of your settings and confirm to save them to `./gitpoll.config.json`. +#### Option 2: Docker + +You can run `gitpoll` in a Docker container using the pre-built image hosted on Docker Hub. This method provides an isolated environment and requires no local installation other than Docker. + +```bash +docker run -it \ + -v $(pwd)/gitpoll.config.json:/app/gitpoll.config.json \ + -v /path/to/your/local/repo:/app/repo \ + starpia/gitpoll:latest +``` + +*Note: Since the application runs via a Terminal UI (TUI) and uses interactive prompts for setup, you need to use the `-it` flag. You should also mount your configuration file and target repository directory using `-v` so the container can access your data and save your settings persistently.* + ## License All code was written by `jules`.