From ff1c940c9b0605dca1556c3c04c37ffa073c5d23 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Fri, 2 Feb 2024 10:37:34 +0100 Subject: [PATCH 1/7] Build go releases --- .github/workflows/publish.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..a245831 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +on: + push + +permissions: + contents: write + packages: write + +jobs: + release-linux-amd64: + name: release linux/amd64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: wangyoucao577/go-release-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: linux + goarch: amd64 From 2bca1fd3a426af5df3dcccd7b97a8387983154f6 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Mon, 5 Feb 2024 13:51:10 +0100 Subject: [PATCH 2/7] Add go mod init --- .github/workflows/publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a245831..5cb67bd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,6 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: | + go mod init gtfstidy + go mod tidy - uses: wangyoucao577/go-release-action@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} From 9606a46cc203e2814c81e343f3dfd167bda9adad Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Mon, 5 Feb 2024 14:13:40 +0100 Subject: [PATCH 3/7] Build docker image --- .github/workflows/publish.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5cb67bd..e05d7cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,8 +14,5 @@ jobs: - run: | go mod init gtfstidy go mod tidy - - uses: wangyoucao577/go-release-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: linux - goarch: amd64 + - run: | + docker build . From b3c8a53509d292e7aaef1333b74b7ea8ae28e875 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Mon, 5 Feb 2024 14:13:55 +0100 Subject: [PATCH 4/7] Add Dockerfile --- .github/workflows/publish.yml | 1 + Dockerfile | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 Dockerfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e05d7cc..65931f7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,5 +14,6 @@ jobs: - run: | go mod init gtfstidy go mod tidy + go build . - run: | docker build . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4092671 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:stable-slim + +LABEL org.opencontainers.image.title="gtfstidy" +LABEL org.opencontainers.image.description="A tool for checking, sanitizing and minimizing GTFS feeds." +LABEL org.opencontainers.image.authors="Patrick Brosi " +LABEL org.opencontainers.image.documentation="https://github.com/patrickbr/gtfstidy" +LABEL org.opencontainers.image.source="https://github.com/patrickbr/gtfstidy" +LABEL org.opencontainers.image.revision="v0.2" +LABEL org.opencontainers.image.licenses="GPL-2.0" + +COPY gtfstidy /usr/local/bin/gtfstidy + +ENTRYPOINT ["/usr/local/bin/gtfstidy"] From b506e305fdbcbfa1164ade9cb8ebf195bbf27aa7 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Mon, 5 Feb 2024 14:36:19 +0100 Subject: [PATCH 5/7] Build container --- .github/workflows/publish.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 65931f7..9efa7f3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,8 +6,7 @@ permissions: packages: write jobs: - release-linux-amd64: - name: release linux/amd64 + container-image: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,5 +14,19 @@ jobs: go mod init gtfstidy go mod tidy go build . + ls -lah - run: | - docker build . + echo "VERSION=$(date +%Y-%m-%dT%H-%M)" >> $GITHUB_ENV + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: lehrenfried/gtfstidy:latest,lehrenfried/gtfstidy:${{ env.VERSION }} From 0aabf0239851d51833790c8c64ca46c1f8878e57 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Mon, 5 Feb 2024 15:03:02 +0100 Subject: [PATCH 6/7] Remove extra ls --- .github/workflows/publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9efa7f3..12b98a1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,10 +14,9 @@ jobs: go mod init gtfstidy go mod tidy go build . - ls -lah - run: | echo "VERSION=$(date +%Y-%m-%dT%H-%M)" >> $GITHUB_ENV - + - name: Login to Docker Hub uses: docker/login-action@v3 with: From 2dc2a4cc3ca6670e669115cbe2814431b8b6925c Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Thu, 15 Feb 2024 13:48:55 +0100 Subject: [PATCH 7/7] Automatically push container image to Github Container Repo --- .github/workflows/container.yml | 46 +++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 31 ---------------------- Dockerfile | 21 ++++++++------- 3 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/container.yml delete mode 100644 .github/workflows/publish.yml 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/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 12b98a1..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,31 +0,0 @@ -on: - push - -permissions: - contents: write - packages: write - -jobs: - container-image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: | - go mod init gtfstidy - go mod tidy - go build . - - run: | - echo "VERSION=$(date +%Y-%m-%dT%H-%M)" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: lehrenfried/gtfstidy:latest,lehrenfried/gtfstidy:${{ env.VERSION }} diff --git a/Dockerfile b/Dockerfile index 4092671..7a7dfe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ -FROM debian:stable-slim +FROM docker.io/golang:bookworm AS builder -LABEL org.opencontainers.image.title="gtfstidy" -LABEL org.opencontainers.image.description="A tool for checking, sanitizing and minimizing GTFS feeds." -LABEL org.opencontainers.image.authors="Patrick Brosi " -LABEL org.opencontainers.image.documentation="https://github.com/patrickbr/gtfstidy" -LABEL org.opencontainers.image.source="https://github.com/patrickbr/gtfstidy" -LABEL org.opencontainers.image.revision="v0.2" -LABEL org.opencontainers.image.licenses="GPL-2.0" +WORKDIR src -COPY gtfstidy /usr/local/bin/gtfstidy +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"]