-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Add Docker support for disability-max-ratings-api #23
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gabezurita
force-pushed
the
add-docker-compose
branch
from
December 19, 2024 01:33
0702147
to
e930afc
Compare
This PR adds Docker support to run the disability-max-ratings-api service in a containerized environment. - Added `Dockerfile` with Python 3.12.3 and Poetry setup - Added `docker-compose.yml` for local development - Added healthcheck to monitor service availability - Fixed Poetry configuration in `pyproject.toml` - Added required `authors` field - Removed unsupported `package-mode` field - Updated the README.MD accordingly 1. Build and start the container: ```bash docker compose up --build ``` 2. Test the API health/docs: ```bash curl http://localhost:8130/docs ``` 3. Test the API endpoint with a sample request: ```bash curl -X POST http://localhost:8130/disability-max-ratings/ \ -H "Content-Type: application/json" \ -d '{"diagnostic_codes": [6260]}' ``` Expected response: ```json { "ratings": [ { "diagnostic_code": 6260, "max_rating": 10 } ] } ``` 4. Monitor container health: ```bash docker compose ps ``` - Uses Python slim base image to minimize container size - Installs only production dependencies with `--only main` - Configures Poetry to run without virtual environments in container - Exposes port 8130 for API access - Includes curl for healthcheck functionality - Mounts local directory for development convenience - Runs with `no-new-privileges` security option - Cleans up apt cache to reduce image size - Uses official Python base image
gabezurita
force-pushed
the
add-docker-compose
branch
from
December 19, 2024 01:34
e930afc
to
ddb7a97
Compare
This commit adds Docker support to the disability-max-ratings-api with a focus on security, maintainability, and developer experience. Key Changes: - Add multi-stage Dockerfile with non-root user for security - Add docker-compose.yml with health monitoring - Create .dockerignore for build optimization - Update pyproject.toml with comprehensive metadata - Update README with Docker setup and testing instructions Technical Details: - Uses Python 3.12.3 slim base image - Implements multi-stage build to reduce final image size - Runs container as non-root user 'appuser' - Configures health monitoring with dedicated endpoint - Mounts local directory for development convenience - Adds security options (no-new-privileges) Next Steps: - Add health endpoint to src/python_src/api.py - Update tests to include health endpoint coverage Testing: ```bash docker compose up --build docker compose run --rm api poetry run pytest ``` Closes #ISSUE_NUMBER</parameter>
brostk
previously approved these changes
Dec 19, 2024
dfitchett
reviewed
Dec 19, 2024
- Update Dockerfile for better dependency management: * Upgrade Poetry to 1.8.5 and add export plugin * Configure Poetry to avoid virtualenv creation * Copy all binaries and config from builder stage * Improve user permissions and security - Enhance docker-compose.yml: * Add PYTHONPATH environment variable * Keep security options and healthcheck - Update README with comprehensive Docker testing guide: * Add structured testing steps * Include expected outputs * Add development and production environment checks * Improve formatting and readability - Update dependencies: * Upgrade ruff to 0.8.4
gabezurita
force-pushed
the
add-docker-compose
branch
from
December 19, 2024 21:42
fc02911
to
4324e47
Compare
@dfitchett and @brostk, this is ready for review! Please run the testing steps on your machine and let me know if the Docker setup makes sense. |
it adds no value
dfitchett
previously approved these changes
Dec 19, 2024
dfitchett
approved these changes
Dec 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Docker Support for Disability Max Ratings API
Closes: #3833
This PR adds Docker support for the disability-max-ratings-api service, providing optimized configurations for both production and development environments.
Changes
Dockerfile:
docker-compose.yml:
api
) and development (api-dev
)/health
endpoint.dockerignore:
pyproject.toml:
README.md:
Production Setup
no-new-privileges
Development Setup
Testing
Build & Start Services
Expected:
disability-max-ratings-api
running on port 8130Check Endpoints
Expected main endpoint response:
Development Environment
Expected: All tests pass (>80% coverage), user should be non-root (uid=1000)
Production Environment
docker compose exec api id docker compose ps
Expected: Non-root user in production container, container status "healthy"
Local Development Checks
Cleanup
Notes
api-dev
service is optional and only needed for development tasks