What's the best practice to use Dockerfile with docker-compose.yml? And how to do CI/CD with Jenkins?
I have 2 microservices and one Postgres database. I create docker-compose.yml file:
version: '3.1'
services:
myflashcards-service-dictionary:
image: myflashcards-service-dictionary
db:
image: postgres
restart: always
ports:
- 5434:5432
The question is what to write in "image:" section? Should I first run
mvn clean install -DskipTests dockerfile:build
? But what with the image name?
I'd like to know how to automate the whole CI/CD.
I have Dockerfile:
FROM openjdk:8-jdk-alpine
ADD target/myflashcards-service-dictionary.jar myflashcards-service-dictionary.jar
ENTRYPOINT exec java -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=$profile -jar /myflashcards-service-dictionary.jar
EXPOSE 8092
I have also docker-compose.yml but how docker-compose.yml know which image should be used?
Would you briefly outline the main process how to deploy my microservices app to the server?
How to use Dockerfile and docker-compose? When are these files necessary? Do we need Dockerfile only to create an image in Docker Hub?
docker-compose.yml
you can use a public image from Docker Hub if you are happy to use an existing image as-is, and you can use a build context if you need to build your own image.