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

Add Docker Compose Deployment with MariaDB #188

Merged
merged 10 commits into from
Feb 22, 2025
Merged

Conversation

Carybe
Copy link
Collaborator

@Carybe Carybe commented Feb 21, 2025

Summary:

This PR adds a Docker Compose configuration to set up a MariaDB instance, replicating the Toolforge infrastructure for local development.

Changes:

  • Introduced docker-compose.yml for easy deployment.
  • Configured MariaDB service to match production settings.

ToDo:

  • Make sure that tests are working perfectly
  • Add sql commands to MariaDB entrypoint so that test databases can be automatically created
  • Documentation of deployment (probably replacing Makefile)
  • Update CI accordingly


volumes:
mariadb_data:
src:
Copy link
Collaborator

Choose a reason for hiding this comment

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

here you are defining a volume named "src", which is not needed because this is not at all related to the "./src" volume defined for the application service.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, I will remove it

"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
"default": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea of 12factor is to have your application code constant and only change things based on environment variables. Here you are introducing conditional logic just for the sake of customizing the set up.

It is better to simply add different environment variables (and use sensible defaults) here and keep your application code the same:

DATABASES = {
"DATABASE_ENGINE": os.getenv("QSTS_DATABASE_ENGINE", "django.db.backends.mysql"),
"DATABASE_HOST": os.getenv("QSTS_DATABASE_HOST", "mariadb"),
"DATABASE_PORT": os.getenv("QSTS_DATABASE_PORT", 3306),
"DATABASE_USER": os.getenv("QSTS_DATABASE_USER", "qsts"),
"DATABASE_PASSWORD": os.getenv("QSTS_DATABASE_PASSWORD"),
}

@Carybe Carybe marked this pull request as draft February 21, 2025 20:50
@arcstur
Copy link
Member

arcstur commented Feb 21, 2025

  • Use root user in the docker-compose (it's dev, no need to complicate with extra users without permissions)
  • Fix the tests by putting DB_ENGINE to sqlite or setup a MariaDB server
  • Stop deploy from running, to perform the migration from SQLite to MariaDB

@Carybe Carybe marked this pull request as ready for review February 22, 2025 01:42
@Carybe Carybe merged commit 9d74c7f into main Feb 22, 2025
2 checks passed
@Carybe Carybe deleted the 2025-02-mariadb-deployment branch February 22, 2025 01:43
@Carybe Carybe restored the 2025-02-mariadb-deployment branch February 22, 2025 02:28
@Carybe Carybe deleted the 2025-02-mariadb-deployment branch February 22, 2025 02:30
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