-
Notifications
You must be signed in to change notification settings - Fork 8
1. Building MySQL images with DB
CLI commands docker:mysql:import-db
or docker:mysql:upload-to-aws
push DB dump to the AWS S3 bucket.
In addition to uploading a DB dump, these CLI commands get MySQL metadata (version, environment variables, my.cnf
configuration)
from the running Docker container. Later this metadata is used to generate a Docker image with the database.
Check documentation for these commands for more information about uploading dumps to AWS S3.
See Using AWS credentials with Dockerizer
to learn more about environment variables.
AWS Lambda is configured to listen to the bucket events. It triggers the GitLab CI/CD pipeline when the DB dump metadata is added or updated in the S3 bucket.
The pipeline runs the docker:mysql:reconstruct-db
command to download files from the S3 bucket and to generate
a DB image from metadata JSON file and a compressed database dump.
You'll have to enter a Docker image name in order for the tool to know where to push the tagged image once it is ready.
Example image name (target_path
in the metadata file): registry.gitlab.com/namespace/project/database-prod
.
In this example, first three parts - domain, namespace, project - match the Git repository.
This way you can push the image to the GitLab Container Registry in the same project.
Always use at least prod
/dev
/etc. suffix to separate databases.
Summary:
- Example GitLab project:
https://gitlab.com/namespace/project
- Docker image name (e.g.
target_image
):registry.gitlab.com/namespace/project/database-prod
- AWS S3 Bucket name:
default-value-php-dept-namespace
. It consists ofDOCKERIZER_AWS_S3_BUCKET_PREFIX
+ project namespace. Can be explicitly passed to the command. - AWS S3 file paths are
s3://default-value-php-dept-namespace/namespace/project/database-prod.json
ands3://default-value-php-dept-namespace/namespace/project/database-prod.sql.gz
for metadata and dump files respectively.
Use Docker label com.default-value.docker.registry.target-image
to store the image name.
Example docker-compose.yaml
:
services:
mysql:
labels:
- com.default-value.docker.registry.target-image=registry.gitlab.com/namespace/project/database-prod
Note that labels are applied only after you restart the composition with the --force-recreate
key.
- docker:mysql:connect
- docker:mysql:export-db
- docker:mysql:import-db
- docker:mysql:upload-to-aws
- docker:mysql:generate-metadata
- docker:mysql:reconstruct-db
- docker:mysql:test-metadata
- magento:setup
- magento:reinstall
- magento:test-module-install
- magento:test-templates
- magento:test-dockerfiles
- MacOS and Docker Desktop support
- Bash aliases
- Install Symfony with Dockerizer
- Running-apps-with-existing-Docker-compositions
- Limitations
- Building MySQL images with DB: how it works
- Configure AWS Lambda
- Gitlab pipeline to build images
- Managing AWS S3 access
- Using AWS credentials with Dockerizer
- Access management cheat-sheet
- FAQ