Skip to content

Comments

[FEATURE] Add Docker Setup and Documentation#1023

Open
pulk17 wants to merge 11 commits intoCCExtractor:masterfrom
pulk17:feature/Docker
Open

[FEATURE] Add Docker Setup and Documentation#1023
pulk17 wants to merge 11 commits intoCCExtractor:masterfrom
pulk17:feature/Docker

Conversation

@pulk17
Copy link

@pulk17 pulk17 commented Feb 16, 2026

Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows (check one):

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

This PR introduces a complete Docker-based development environment for the Sample Platform. It allows developers to spin up the entire application stack (Flask + MySQL) with a single command, eliminating manual dependency installation and configuration headaches.

Key Features

  • One-Command Setup: docker compose up --build handles everything from database creation to dependency installation.
  • Live Code Reloading: The local source code is mounted into the container, so changes are reflected immediately without rebuilding.
  • Automated Database Management:
    • Automatically waits for MySQL to be healthy.
    • Handles schema creation and migration stamping (flask db stamp head) on the first run.
    • Seeds the database with an admin user and sample data (configurable via .env).
  • Google Cloud Storage (GCS) Emulation:
    • Automatically generates a dummy service-account.json if one is missing, preventing startup crashes.
    • Supports mounting a real GCS bucket via gcsfuse if credentials are provided.
  • Security Best Practices:
    • SECRET_KEY and CSRF_SESSION_KEY are generated at runtime.
    • Runs with a non-root user (Gunicorn).

File Overview

  • Dockerfile: Multi-stage build based on Python 3.11-slim.
  • docker-compose.yml: Orchestrates the Flask backend and MySQL 8.0 database.
  • docker-entrypoint.sh: A robust startup script that handles:
    • Secret key generation.
    • Git repository initialization (required for build commit display).
    • Database waiting and migration strategies.
    • Gunicorn execution.
  • DOCKER.md: Comprehensive documentation on usage, architecture, and troubleshooting.
  • env.example: A template for environment variables tailored for Docker.
  • .dockerignore: Optimizes build context by excluding unnecessary files.

Design Decisions & Trade-offs

  • Runtime Secrets: We generate secrets in the entrypoint instead of the Dockerfile to prevent leaking them in image layers and to ensure every container has unique keys.
  • GCS Mounting: We mount GCS buckets to /mnt/gcs_repository instead of directly to /repository to avoid conflicts with Docker's volume mounting behavior.
  • Database Stamping: On a fresh DB, we use flask db stamp head because create_all() builds the schema faster than running 50+ migrations sequentially.

Documentation: See DOCKER.md for full details.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

1 participant