Skip to content

Conversation

@colinbjohnson
Copy link

@colinbjohnson colinbjohnson commented Jul 26, 2025

This PR will:

  1. Add a Dockerfile and entrypoint.sh file to run ./get_usage_report.py and, optionally, ./send_to_datadog.py.
  2. Update the README.md to provide some instructions for building and running the given docker image.
  3. Add a requirements.txt file (so that python packages can be installed in the Docker Image)
  4. Make src/send_to_datadog.py executable
  5. Add a "shebang" line #!/usr/bin/env python3 to get_usage_report.py so that the shell knows to run get_usage_report.py using python3.

@colinbjohnson colinbjohnson requested a review from Copilot July 26, 2025 04:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Similar to get_usage_report.py, this script assumes send_to_datadog.py is executable, but no execute permissions are set in the Dockerfile.

Suggested change
if [ -e "$csv_file" ]; then
if [ -e "$csv_file" ]; then
chmod +x ./send_to_datadog.py

Copilot uses AI. Check for mistakes.
COPY src/ ./
COPY requirements.txt ./
COPY entrypoint.sh ./

Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

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

Suggested change
RUN chmod +x entrypoint.sh

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants