diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..f24c30f --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,46 @@ +name: "Container image build" + +on: + push: + branches: [ master ] + pull_request: + +jobs: + + image: + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value={{date 'YYYY-MM-DDTHH-mm'}} + type=raw,value=latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.ref == 'refs/heads/master' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a7dfe3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM docker.io/golang:bookworm AS builder + +WORKDIR src + +COPY *.go ./ +COPY processors/ ./processors/ + +RUN go mod init gtfstidy +RUN go mod tidy +RUN go build . + +FROM docker.io/debian:stable-slim + +COPY --from=builder /go/src/gtfstidy /usr/local/bin/gtfstidy + +ENTRYPOINT ["/usr/local/bin/gtfstidy"]