This answer describes the essentials of the database container, including the commands used and the Dockerfile.
I imported the image my-postgres-image.
Then, I created a volume called my-postgres-volume.
The following command is used to create and run the container named my-postgresdb. This container is based on the my-postgres-image and uses the Dockerfile for configuration. The -v option is used to mount the my-postgres-volume at the /var/lib/postgresql/data directory in the container.
docker run --name my-postgresdb --network app-network -d -p 5432:5432 -v my-postgres-volume:/var/lib/postgresql/data my-postgres-imageAfter executing this command, we will be able to connect to the database on port 5432 thanks to the adminer app-network. It will run in background following the dockerfile.
FROM postgres:14.1-alpine
ENV POSTGRES_DB=db
POSTGRES_USER=usr
POSTGRES_PASSWORD=pwd
COPY ./init.sql /docker-entrypoint-initdb.d/10-CreateScheme.sql
COPY ./InsertData.sql /docker-entrypoint-initdb.d/20-insert-data.sql
The multistage build is very useful to make the servor run without paying attention to the version of local softwares as we build a java image with docker. We can configurate a build that install exactly the installation of the application configuration.
More globally, it makes sure that every component of the configuration work together.
FROM maven:3.8.6-amazoncorretto-17 AS myapp-build
ENV MYAPP_HOME /opt/myapp WORKDIR $MYAPP_HOME
COPY pom.xml .
COPY src ./src
Run the maven package to compile the application and precises to skip the tests so that it does not take too long.
RUN mvn package -DskipTests
FROM amazoncorretto:17 ENV MYAPP_HOME /opt/myapp WORKDIR $MYAPP_HOME
COPY --from=myapp-build $MYAPP_HOME/target/*.jar $MYAPP_HOME/myapp.jar
ENTRYPOINT java -jar myapp.jar
docker run -p 8000:8080 -it --network app-network --name my-spring-boot myappdocker run -d --network app-network -p 8082:80 --name my-http-container my-httpdocker-compose build # Configure the containers and images.
docker-compose up # Launch all the containers to make the web application accessible
docker-compose down -v # Stop and delete all containers, images and volumes involved. The testcontainers provide the needed tools to test the created containers regarding their dependencies.
chmod 400 /mnt/wsl/id_rsa #set the good rights to id_rsa ansible -i ansible/inventories/setup.yml all -m ping #Test the connectivity of the host in the inventory ansible all -i inventories/setup.yml -m setup -a "filter=ansible_distribution*" #setup the module with patterns that match ansible_distribution ansible all -i inventories/setup.yml -m yum -a "name=httpd state=absent" --become #Ensure that apache httpd server is not installed.