Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds Docker containerization support to the CircleCI usage API exporter project. It introduces a Dockerfile and associated configuration to enable running the application in a containerized environment.
- Added Dockerfile with Python 3.12 slim base image and dependency installation
- Created entrypoint.sh script to orchestrate running the usage report generation and optional Datadog submission
- Updated Python script with shebang for direct execution
- Added comprehensive Docker usage documentation with examples
Reviewed Changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Dockerfile | Defines container image with Python 3.12, sets up working directory, and installs dependencies |
| entrypoint.sh | Shell script that executes the main workflow and conditionally sends reports to Datadog |
| src/get_usage_report.py | Added shebang line for direct script execution |
| README.md | Added Docker usage section with build and run examples |
| #!/bin/bash | ||
| set -e | ||
|
|
||
| ./get_usage_report.py |
There was a problem hiding this comment.
The script assumes get_usage_report.py is executable, but the Dockerfile doesn't set execute permissions. This will cause a permission denied error when the container runs.
| if [ "${SEND_TO_DATADOG}" = "true" ]; then | ||
| for csv_file in /tmp/reports/*.csv; do | ||
| # Check if the file actually exists (in case the glob didn't match anything) | ||
| if [ -e "$csv_file" ]; then |
There was a problem hiding this comment.
Similar to get_usage_report.py, this script assumes send_to_datadog.py is executable, but no execute permissions are set in the Dockerfile.
| if [ -e "$csv_file" ]; then | |
| if [ -e "$csv_file" ]; then | |
| chmod +x ./send_to_datadog.py |
| COPY src/ ./ | ||
| COPY requirements.txt ./ | ||
| COPY entrypoint.sh ./ | ||
|
|
There was a problem hiding this comment.
The entrypoint.sh script needs execute permissions to run properly. Add a RUN command after the COPY operations to set execute permissions: RUN chmod +x entrypoint.sh get_usage_report.py send_to_datadog.py
| RUN chmod +x entrypoint.sh |
This PR will:
Dockerfileandentrypoint.shfile to run./get_usage_report.pyand, optionally,./send_to_datadog.py.README.mdto provide some instructions for building and running the given docker image.requirements.txtfile (so that python packages can be installed in the Docker Image)src/send_to_datadog.pyexecutable#!/usr/bin/env python3toget_usage_report.pyso that the shell knows to runget_usage_report.pyusing python3.