Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize ciplatforms CLI app 🐳 #26

Merged
merged 3 commits into from
Nov 18, 2024
Merged
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
7 changes: 7 additions & 0 deletions ciplatforms/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Exclude everything by default
*

# Except for Go source files and Go dependency files
!**/*.go
!go.mod
!go.sum
17 changes: 17 additions & 0 deletions ciplatforms/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.23 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" ]
26 changes: 26 additions & 0 deletions ciplatforms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Loading