Docker image containing a PostgreSQL database and a schema migrator to simplify database schema upgrades.
Use the provided Makefile to build the Docker image and prepare the context:
make allThis will download Flyway, prepare the build context, and build the Docker image.
After building, run:
make runOr directly with Docker:
docker run --name pg-flyway-test -e POSTGRES_DB=postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -p 5432:5432 localhost.localdomain/postgresql-container:1.1.0-SNAPSHOTUse the following JDBC URL to connect to the database:
jdbc:postgresql://localhost:5432/postgres
Username: postgres Password: password
Flyway is integrated via the commandline tool in the Docker container. Migration scripts should be placed in:
build/db/migration/
Scripts must follow the naming pattern:
SPRINT<zero padded three digit sprint number>_<zero padded two digit script order number>__<description>.sql
Example: SPRINT001_01__Initial_database_revision.sql
To remove all build artifacts, Docker containers, and images, use:
make distcleanThis will stop and remove the Docker container and image, and clean build artifacts.
By default, all command output is sent to the console. Output suppression is now controlled by the --silent argument: when you run Make with --silent, output from Docker and other commands is hidden. If you want to see all command output (for troubleshooting or detailed build information), simply omit the --silent flag:
make <target>To suppress output, use:
make --silent <target>For more information, see the help target in the Makefile (make help).
- PostgreSQL
- Flyway
- postgres - Docker Official Images
- Docker Library PostgreSQL on GitHub
- "exec: "docker-entrypoint.sh": executable file not found in $PATH". #296
- Sending RUN ["docker-entrypoint.sh", "postgres", "--version"] output to the console during the build #718
- Functionalize the entrypoint to allow outside sourcing for extreme customizing of startup #496