Skip to content

Commit

Permalink
Merge branch 'spring-petclinic:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhakamath authored Dec 28, 2023
2 parents fac4bbd + 159be8f commit 63199af
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 42 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Alternatively you can also build all the images on Podman, which requires Podman
Once images are ready, you can start them with a single command
`docker-compose up` or `podman-compose up`.

Containers startup order is coordinated with [`dockerize` script](https://github.com/jwilder/dockerize).
Containers startup order is coordinated with the `service_healthy` condition of the Docker Compose [depends-on](https://github.com/compose-spec/compose-spec/blob/master/spec.md#depends_on) expression
and the [healthcheck](https://github.com/compose-spec/compose-spec/blob/master/spec.md#healthcheck) of the service containers.
After starting services, it takes a while for API Gateway to be in sync with service registry,
so don't be scared of initial Spring Cloud Gateway timeouts. You can track services availability using Eureka dashboard
available by default at http://localhost:8761.
Expand Down
101 changes: 73 additions & 28 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,106 @@
version: '2'
version: '3'

services:
config-server:
image: springcommunity/spring-petclinic-config-server
container_name: config-server
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
healthcheck:
test: ["CMD", "curl", "-I", "http://config-server:8888"]
interval: 5s
timeout: 5s
retries: 10
ports:
- 8888:8888

discovery-server:
image: springcommunity/spring-petclinic-discovery-server
container_name: discovery-server
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
healthcheck:
test: ["CMD", "curl", "-f", "http://discovery-server:8761"]
interval: 5s
timeout: 3s
retries: 10
depends_on:
- config-server
entrypoint: ["./dockerize","-wait=tcp://config-server:8888","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
ports:
- 8761:8761

customers-service:
image: springcommunity/spring-petclinic-customers-service
container_name: customers-service
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
discovery-server:
condition: service_healthy
ports:
- 8081:8081

visits-service:
image: springcommunity/spring-petclinic-visits-service
container_name: visits-service
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
discovery-server:
condition: service_healthy
ports:
- 8082:8082

vets-service:
image: springcommunity/spring-petclinic-vets-service
container_name: vets-service
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
discovery-server:
condition: service_healthy
ports:
- 8083:8083

api-gateway:
image: springcommunity/spring-petclinic-api-gateway
container_name: api-gateway
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
discovery-server:
condition: service_healthy
ports:
- 8080:8080

tracing-server:
image: openzipkin/zipkin
container_name: tracing-server
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
environment:
- JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -Djava.security.egd=file:/dev/./urandom
ports:
Expand All @@ -74,11 +109,15 @@ services:
admin-server:
image: springcommunity/spring-petclinic-admin-server
container_name: admin-server
mem_limit: 512M
deploy:
resources:
limits:
memory: 512M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
discovery-server:
condition: service_healthy
ports:
- 9090:9090

Expand All @@ -87,13 +126,19 @@ services:
grafana-server:
build: ./docker/grafana
container_name: grafana-server
mem_limit: 256M
deploy:
resources:
limits:
memory: 256M
ports:
- 3000:3000

prometheus-server:
build: ./docker/prometheus
container_name: prometheus-server
mem_limit: 256M
deploy:
resources:
limits:
memory: 256M
ports:
- 9091:9090
10 changes: 0 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@ ARG ARTIFACT_NAME
COPY ${ARTIFACT_NAME}.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract

# Download dockerize and cache that layer
ARG DOCKERIZE_VERSION
RUN wget -O dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz
RUN tar xzf dockerize.tar.gz
RUN chmod +x dockerize


FROM eclipse-temurin:17

WORKDIR application

# Dockerize
COPY --from=builder application/dockerize ./

ARG EXPOSED_PORT
EXPOSE ${EXPOSED_PORT}

Expand Down
3 changes: 0 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<docker.image.prefix>springcommunity</docker.image.prefix>
<docker.image.exposed.port>9090</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}</docker.image.dockerfile.dir>
<docker.image.dockerize.version>v0.6.1</docker.image.dockerize.version>
<container.executable>docker</container.executable>
</properties>

Expand Down Expand Up @@ -153,8 +152,6 @@
<argument>ARTIFACT_NAME=${project.build.finalName}</argument>
<argument>--build-arg</argument>
<argument>EXPOSED_PORT=${docker.image.exposed.port}</argument>
<argument>--build-arg</argument>
<argument>DOCKERIZE_VERSION=${docker.image.dockerize.version}</argument>
<argument>-t</argument>
<argument>${docker.image.prefix}/${project.artifactId}</argument>
<argument>${project.build.directory}</argument>
Expand Down

0 comments on commit 63199af

Please sign in to comment.