A repo for webapp consumer microservice
The Application Contains 2 Dockerfiles one for building the webapp and the other for building the flyway image. The flyway image contains the DB migrations and is used as an init container to run the migrations before the application starts.
To run the application locally: Run the Postgres DB using the following compose file:
version: '3.8'
services:
psql:
image: postgres:14
environment:
POSTGRES_DB: ${DB_DATABASE}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- 5432:5432
volumes:
psql_volume:
docker run -e DB_DATABASE=your_database -e DB_PASSWORD=your_password -e DB_USERNAME=your_username -e DB_PORT=your_port -e DB_HOST=your_host your_image
To build the flyway image locally use the following commands:
you need to specify the --network="host" to connect with postgres db which is running locally
docker build -t my-flyway-image -f Dockerfile.flyway .
docker run --network="host" --env-file .env $Image_Name
Flyway is used to manage the database schema. The schema is stored in the resources/db/migration folder. The schema is versioned and flyway will apply the schema to the database when the application starts.
Create a flyway.conf file in the resources folder with the following content:
flyway.url=jdbc:postgresql://dbhost:port/dbname
flyway.user=username
flyway.password=password
flyway.locations=filesystem:./migration
The number of consumers can be customized it is currently set to 10.
docker run --network="host" -it my-flyway-image migrate -X