[FEATURE] Add Docker Setup and Documentation#1023
Conversation
… sonarqube errors
|
| } | ||
| raise SampleNotFoundException(f"Extra file {additional_id} for sample {sample.id} not found") | ||
| raise SampleNotFoundException(f"Sample with id {sample_id} not found") | ||
| raise SampleNotFoundException(f"Sample with id {sample_id} not found") No newline at end of file |
There was a problem hiding this comment.
Remove this change please.
| service-account.json | ||
| gcp-key.json | ||
| secret_key | ||
| secret_csrf No newline at end of file |
There was a problem hiding this comment.
Add a newline to the end.
| @@ -0,0 +1,64 @@ | |||
| services: | |||
| # --- 1. Database Service --- | |||
There was a problem hiding this comment.
Please remove all these unnecessary comments.
| python3 -c " | ||
| import json | ||
| from cryptography.hazmat.primitives.asymmetric import rsa | ||
| from cryptography.hazmat.primitives import serialization | ||
|
|
||
| try: | ||
| key = rsa.generate_private_key(public_exponent=65537, key_size=2048) | ||
| pem = key.private_bytes(serialization.Encoding.PEM, | ||
| serialization.PrivateFormat.TraditionalOpenSSL, | ||
| serialization.NoEncryption()).decode() | ||
| except Exception as e: | ||
| print(f'WARNING: Key generation failed: {e}') | ||
| pem = 'DUMMY_KEY' | ||
|
|
||
| sa = { | ||
| 'type': 'service_account', | ||
| 'project_id': 'docker-dev', | ||
| 'private_key_id': 'docker-dev-key', | ||
| 'private_key': pem, | ||
| 'client_email': 'docker-dev@docker-dev.iam.gserviceaccount.com', | ||
| 'client_id': '000000000000', | ||
| 'auth_uri': 'https://accounts.google.com/o/oauth2/auth', | ||
| 'token_uri': 'https://oauth2.googleapis.com/token', | ||
| } | ||
| with open('$REAL_SA_PATH', 'w') as f: | ||
| json.dump(sa, f, indent=2) | ||
| " |
There was a problem hiding this comment.
I'd rather see extra helper files (in the correct subfolder) than almost unreadable python in a shell script.
| @@ -0,0 +1,292 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
This file is way too large for a entrypoint of a docker. A lot of these things should be handled at build time (ensuring dirs exist/created etc).
| @@ -0,0 +1,81 @@ | |||
| FROM python:3.11-slim-bullseye | |||
There was a problem hiding this comment.
I'd rather see a more recent python version.
| # ============================================================ | ||
|
|
||
| # ---------- MySQL ---------- | ||
| MYSQL_ROOT_PASSWORD=root |
There was a problem hiding this comment.
The SP does not need to know the root password for MYSQL
| # Port exposed on the HOST for the Flask app (container always listens on 5000) | ||
| APP_PORT=5000 | ||
| # Port exposed on the HOST for direct MySQL access (optional, for debugging) | ||
| DB_EXTERNAL_PORT=3306 |
There was a problem hiding this comment.
This should not be exposed.




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):
My familiarity with the project is as follows (check one):
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
docker compose up --buildhandles everything from database creation to dependency installation.flask db stamp head) on the first run..env).service-account.jsonif one is missing, preventing startup crashes.gcsfuseif credentials are provided.SECRET_KEYandCSRF_SESSION_KEYare generated at runtime.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: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
/mnt/gcs_repositoryinstead of directly to/repositoryto avoid conflicts with Docker's volume mounting behavior.flask db stamp headbecausecreate_all()builds the schema faster than running 50+ migrations sequentially.Documentation: See
DOCKER.mdfor full details.