From 9e5ffb1afe012304370674ad6bf51687d3a1e95e Mon Sep 17 00:00:00 2001 From: Raphael Aurich Date: Mon, 18 Nov 2024 16:38:29 +0100 Subject: [PATCH 1/3] feat: Dockerize ciplatforms CLI app --- ciplatforms/.dockerignore | 7 +++++++ ciplatforms/Dockerfile | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 ciplatforms/.dockerignore create mode 100644 ciplatforms/Dockerfile diff --git a/ciplatforms/.dockerignore b/ciplatforms/.dockerignore new file mode 100644 index 0000000..ae9553a --- /dev/null +++ b/ciplatforms/.dockerignore @@ -0,0 +1,7 @@ +# Exclude everything by default +* + +# Except for Go source files and Go dependency files +!**/*.go +!go.mod +!go.sum diff --git a/ciplatforms/Dockerfile b/ciplatforms/Dockerfile new file mode 100644 index 0000000..40dd705 --- /dev/null +++ b/ciplatforms/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.22 AS builder + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux go build -o /app/ciplatforms + +FROM gcr.io/distroless/static-debian12:nonroot + +COPY --from=builder /app/ciplatforms /app/ciplatforms + +ENTRYPOINT [ "/app/ciplatforms" ] From 118beb80937e238d86eb7218fb077832a4d9b37f Mon Sep 17 00:00:00 2001 From: Raphael Aurich Date: Mon, 18 Nov 2024 17:32:35 +0100 Subject: [PATCH 2/3] docs: Add Docker section to README --- ciplatforms/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ciplatforms/README.md b/ciplatforms/README.md index 57ad62a..427fb19 100644 --- a/ciplatforms/README.md +++ b/ciplatforms/README.md @@ -137,3 +137,29 @@ repository, including its accessibility (a repository may be inaccessible if it does not exist or if the provided authentication token lacks access), and flags indicating the presence of CircleCI, GitHub Actions, and Taskcluster configuration files. + +## Docker + +You can also run the `ciplatforms` app as a Docker container. + +### Build the Docker Image + +To build the Docker image, use the following command: + +```bash +docker build -t ciplatforms:latest . +``` + +### Run the Docker Container + +To run the `info` subcommand inside the Docker container, mount the directory +containing the input and output files as a volume and pass the required +environment variable: + +```bash +docker run --rm \ + -e CIPLATFORMS_GITHUB_API_TOKEN \ + -v $(pwd)/data:/data \ + ciplatforms:latest \ + info --input /data/services.csv --output /data/services_out.json +``` From 50747174409423249029eed6858e0503efaacf13 Mon Sep 17 00:00:00 2001 From: Raphael Aurich Date: Mon, 18 Nov 2024 17:46:07 +0100 Subject: [PATCH 3/3] chore: Upgrade Docker builder image --- ciplatforms/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciplatforms/Dockerfile b/ciplatforms/Dockerfile index 40dd705..6560423 100644 --- a/ciplatforms/Dockerfile +++ b/ciplatforms/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22 AS builder +FROM golang:1.23 AS builder WORKDIR /app