Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM docker.io/golang:bookworm AS builder

WORKDIR src

COPY *.go ./
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go.mod and go.sum are missing.

This will allow to remove the go mod commands below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. However I'm a little reluctant to work on this as this PR has been open for a while and I've not received any feedback from the repo owner.

COPY processors/ ./processors/

RUN go mod init gtfstidy
RUN go mod tidy
RUN go build .

FROM docker.io/debian:stable-slim

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add OCI annotations, to provide helpful machine-readable infos to a variety of tools.

Suggested change
FROM docker.io/debian:stable-slim
FROM docker.io/debian:stable-slim
LABEL org.opencontainers.image.title="oxygen-xml"
LABEL org.opencontainers.image.description="A tool for checking, sanitizing and minimizing GTFS feeds."
LABEL org.opencontainers.image.authors="Patrick Brosi <[email protected]>"
LABEL org.opencontainers.image.source="https://github.com/patrickbr/gtfstidy"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker/metadata-action actually already adds most (all?) of these labels from the GitHub metadata.

Can you check the pfaedle image (which uses the same process) to see if you're missing something? https://github.com/ad-freiburg/pfaedle/pkgs/container/pfaedle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know. Consider this thread irrelevant then.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A smaller base image would be better.

Ideally only the binary and tzdata.


COPY --from=builder /go/src/gtfstidy /usr/local/bin/gtfstidy

ENTRYPOINT ["/usr/local/bin/gtfstidy"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move entrypoint above for a better use of layers, as the binary changes more often.