2.1.2โ
Changedโ
Documentation for Logging: Database Deployment Optimization and Docker Image Buildingโ
Introductionโ
This documentation details the optimization implemented in the database deployment process, which consequently facilitated the construction of the Docker image for the application. This procedure is an essential part of ensuring efficient and safe deployment of the application in a container environment.
File Structure and Scriptsโ
Schema files (.prisma):
mongodb-schema.prisma
,mysql-schema.prisma
,postgresql-schema.prisma
: Define the schemas of the MongoDB, MySQL and PostgreSQL databases, respectively.- Function: Structure the database according to the chosen provider.
Configuration File (.env.dev):
- Contains the environment variables, including database settings.
- Function: Provides crucial information for connecting and configuring the database.
Dockerfile:
- Defines the instructions for building the application's Docker image.
- Function: Uses environment variables to configure the application, including connection to the database.
Database Operation Scripts (.sh):
env_functions.sh
: Manipulates and exports environment variables.run_database_operation_deploy.sh
,run_database_operation_generate.sh
,run_database_operation_migrate.sh
: Execute database deployment, generation and migration operations.setup_database_url.sh
: Configures the database URL.- Function: Automate the configuration process and database operations.
Optimizations Implementedโ
Database Configuration Automation:
- The implementation of scripts such as
setup_database_url.sh
andenv_functions.sh
automated the configuration of database connection variables, reducing manual errors and speeding up the setup process.
- The implementation of scripts such as
Integration with Dockerfile:
.env.dev
environment variables are embedded in the Dockerfile, ensuring that the built Docker image is aligned with the database configurations.- This integration ensures consistency between the development and production environment.
Flexibility in Schema Management:
- The use of specific schema files for each type of database (MongoDB, MySQL, PostgreSQL) in the
prisma
directory allows flexibility and ease in migrating or changing the database.
- The use of specific schema files for each type of database (MongoDB, MySQL, PostgreSQL) in the
Database Operation Scripts:
- Scripts like
run_database_operation_migrate.sh
facilitate critical operations such as migrations, making them an integral part of the CI/CD process, which reduces deployment time and possible failures.
- Scripts like
Conclusionโ
Optimization of the database deployment process and integration with Docker image construction provided a more efficient and reliable workflow. These improvements not only speed up the deployment process, but also ensure that the application is always synchronized with the database settings, regardless of the execution environment. This procedure is a clear example of how automation and good configuration management can positively impact the software development lifecycle.