[ BAEL-5503 ] - Difference Between links and depends_on in Docker-Compose (#12503)
* updates pom-xml and adds Dockerfile to build a web-app image * add depends-on vs links yml examples
This commit is contained in:
parent
b6e04505ef
commit
09651da81e
4
docker-modules/docker-compose/Dockerfile
Normal file
4
docker-modules/docker-compose/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM openjdk:11
|
||||
MAINTAINER baeldung.com
|
||||
COPY target/docker-compose-0.0.1-SNAPSHOT.jar app.jar
|
||||
ENTRYPOINT ["java","-jar","/app.jar"]
|
@ -0,0 +1,14 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:latest
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
web-app:
|
||||
image: web-app:latest
|
||||
ports:
|
||||
- 8080:8080
|
||||
depends_on:
|
||||
- db
|
@ -0,0 +1,14 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:latest
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
web-app:
|
||||
image: web-app:latest
|
||||
ports:
|
||||
- 8080:8080
|
||||
links:
|
||||
- db
|
@ -0,0 +1,36 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:latest
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
networks:
|
||||
- mynet
|
||||
|
||||
web-app:
|
||||
image: web-app:latest
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- mynet
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
DB_HOST: db
|
||||
DB_PORT: 5432
|
||||
DB_USER: postgres
|
||||
DB_PASSWORD: postgres
|
||||
DB_NAME: postgres
|
||||
|
||||
networks:
|
||||
mynet:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
db:
|
||||
driver: local
|
@ -34,6 +34,16 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.docker.app.DockAppApplication</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
Loading…
x
Reference in New Issue
Block a user