Skip to content
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

# Enhance CCDB Web and Database Deployment with Docker #102

Open
wants to merge 1 commit into
base: v2-main
Choose a base branch
from

Conversation

mrcmor100
Copy link

Summary

  • Build a test database (test_ccdb) from ccdb.mysql.sql following proper SQL dump ordering.
  • Add a custom test_user with test_password for local development and deployment.
  • Utilize Docker Compose for a cohesive network setup, database volumes, and containerized builds.
  • Streamline web deployment with a requirements-web.txt file, adding cryptography for SQLAlchemy provider compatibility.
  • Abstracted the app component from ccdbweb.py's __main__ for Gunicorn-based deployment, exposing it to external IPs from the container.
  • Goal: Enable seamless deployment and local testing of ccdbweb.

Key Changes

Docker Compose

  • Defined services for:
    • mysqldb: Builds and initializes the database using MySQL with SQL dump files.
    • webgui: Builds the Flask-based ccdbweb GUI and connects to mysqldb.
  • Volume setup:
    • Persist MySQL data with mysql_data.
    • Load initialization SQL files with mysql_init_data.
  • Enabled network connectivity between containers using app_network.

Dockerfiles

  • MySQL (docker/mysqldb/Dockerfile):
    • Added SQL initialization scripts (test_user_init.sql, ccdb.mysql.sql) with numeric prefixes for proper execution order.
    • Exposed port 3306.
  • Web GUI (docker/webgui/Dockerfile):
    • Added requirements-web.txt for web-specific dependencies.
    • Used Gunicorn for serving the application with 4 worker processes.
    • Exposed port 5000.

Code Updates

  • ccdbweb.py:
    • Abstracted Flask app creation to be compatible with Gunicorn.
    • Added SQL_CONNECTION_STRING for flexible database connectivity using environment variables.
  • requirements-web.txt:
    • Added Flask, Bokeh, and Gunicorn dependencies.
  • requirements.txt:
    • Added cryptography to address SQLAlchemy provider needs.

Usage Instructions

To run the ccdbweb application locally with the test database:

  1. Start the containers: ```bash cd docker docker-compose up --build
  2. Check the website in a browser: ```bash localhost:5000

## Summary

- Build a test database (`test_ccdb`) from `ccdb.mysql.sql` following proper SQL dump ordering.
- Add a custom `test_user` with `test_password` for local development and deployment.
- Utilize Docker Compose for a cohesive network setup, database volumes, and containerized builds.
- Streamline web deployment with a `requirements-web.txt` file, adding `cryptography` for SQLAlchemy provider compatibility.
- Abstracted the app component from `ccdbweb.py`'s `__main__` for Gunicorn-based deployment, exposing it to external IPs from the container.
- Goal: Enable seamless deployment and local testing of `ccdbweb`.

## Key Changes

### Docker Compose
- Defined services for:
  - `mysqldb`: Builds and initializes the database using MySQL with SQL dump files.
  - `webgui`: Builds the Flask-based `ccdbweb` GUI and connects to `mysqldb`.
- Volume setup:
  - Persist MySQL data with `mysql_data`.
  - Load initialization SQL files with `mysql_init_data`.
- Enabled network connectivity between containers using `app_network`.

### Dockerfiles
- **MySQL (`docker/mysqldb/Dockerfile`):**
  - Added SQL initialization scripts (`test_user_init.sql`, `ccdb.mysql.sql`) with numeric prefixes for proper execution order.
  - Exposed port `3306`.
- **Web GUI (`docker/webgui/Dockerfile`):**
  - Added `requirements-web.txt` for web-specific dependencies.
  - Used Gunicorn for serving the application with 4 worker processes.
  - Exposed port `5000`.

### Code Updates
- **`ccdbweb.py`:**
  - Abstracted Flask app creation to be compatible with Gunicorn.
  - Added `SQL_CONNECTION_STRING` for flexible database connectivity using environment variables.
- **`requirements-web.txt`:**
  - Added Flask, Bokeh, and Gunicorn dependencies.
- **`requirements.txt`:**
  - Added `cryptography` to address SQLAlchemy provider needs.

## Usage Instructions
To run the `ccdbweb` application locally with the test database:
1. Start the containers:
   ```bash
   cd docker
   docker-compose up --build
2. Check the website in a browser:
   ```bash
   localhost:5000
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