Skip to content

Commit 0c4ee53

Browse files
authored
Remove dockerize in favor of docker-compose features (spring-petclinic#247)
* Use Github Actions for CI * spring-petclinic#219 Upgrade to docker-compose v3 * spring-petclinic#219 Remove dockerize from the Dockerfile and add some healthcheck and depends_on to the docker-compose.yml * spring-petclinic#219 Complete Dockerize removal
1 parent e4a9e92 commit 0c4ee53

File tree

4 files changed

+75
-42
lines changed

4 files changed

+75
-42
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Alternatively you can also build all the images on Podman, which requires Podman
3333
Once images are ready, you can start them with a single command
3434
`docker-compose up` or `podman-compose up`.
3535

36-
Containers startup order is coordinated with [`dockerize` script](https://github.com/jwilder/dockerize).
36+
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
37+
and the [healthcheck](https://github.com/compose-spec/compose-spec/blob/master/spec.md#healthcheck) of the service containers.
3738
After starting services, it takes a while for API Gateway to be in sync with service registry,
3839
so don't be scared of initial Spring Cloud Gateway timeouts. You can track services availability using Eureka dashboard
3940
available by default at http://localhost:8761.

docker-compose.yml

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,106 @@
1-
version: '2'
1+
version: '3'
22

33
services:
44
config-server:
55
image: springcommunity/spring-petclinic-config-server
66
container_name: config-server
7-
mem_limit: 512M
7+
deploy:
8+
resources:
9+
limits:
10+
memory: 512M
11+
healthcheck:
12+
test: ["CMD", "curl", "-I", "http://config-server:8888"]
13+
interval: 5s
14+
timeout: 5s
15+
retries: 10
816
ports:
917
- 8888:8888
1018

1119
discovery-server:
1220
image: springcommunity/spring-petclinic-discovery-server
1321
container_name: discovery-server
14-
mem_limit: 512M
22+
deploy:
23+
resources:
24+
limits:
25+
memory: 512M
26+
healthcheck:
27+
test: ["CMD", "curl", "-f", "http://discovery-server:8761"]
28+
interval: 5s
29+
timeout: 3s
30+
retries: 10
1531
depends_on:
16-
- config-server
17-
entrypoint: ["./dockerize","-wait=tcp://config-server:8888","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
32+
config-server:
33+
condition: service_healthy
1834
ports:
1935
- 8761:8761
2036

2137
customers-service:
2238
image: springcommunity/spring-petclinic-customers-service
2339
container_name: customers-service
24-
mem_limit: 512M
40+
deploy:
41+
resources:
42+
limits:
43+
memory: 512M
2544
depends_on:
26-
- config-server
27-
- discovery-server
28-
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
45+
config-server:
46+
condition: service_healthy
47+
discovery-server:
48+
condition: service_healthy
2949
ports:
3050
- 8081:8081
3151

3252
visits-service:
3353
image: springcommunity/spring-petclinic-visits-service
3454
container_name: visits-service
35-
mem_limit: 512M
55+
deploy:
56+
resources:
57+
limits:
58+
memory: 512M
3659
depends_on:
37-
- config-server
38-
- discovery-server
39-
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
60+
config-server:
61+
condition: service_healthy
62+
discovery-server:
63+
condition: service_healthy
4064
ports:
4165
- 8082:8082
4266

4367
vets-service:
4468
image: springcommunity/spring-petclinic-vets-service
4569
container_name: vets-service
46-
mem_limit: 512M
70+
deploy:
71+
resources:
72+
limits:
73+
memory: 512M
4774
depends_on:
48-
- config-server
49-
- discovery-server
50-
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
75+
config-server:
76+
condition: service_healthy
77+
discovery-server:
78+
condition: service_healthy
5179
ports:
5280
- 8083:8083
5381

5482
api-gateway:
5583
image: springcommunity/spring-petclinic-api-gateway
5684
container_name: api-gateway
57-
mem_limit: 512M
85+
deploy:
86+
resources:
87+
limits:
88+
memory: 512M
5889
depends_on:
59-
- config-server
60-
- discovery-server
61-
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
90+
config-server:
91+
condition: service_healthy
92+
discovery-server:
93+
condition: service_healthy
6294
ports:
6395
- 8080:8080
6496

6597
tracing-server:
6698
image: openzipkin/zipkin
6799
container_name: tracing-server
68-
mem_limit: 512M
100+
deploy:
101+
resources:
102+
limits:
103+
memory: 512M
69104
environment:
70105
- JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -Djava.security.egd=file:/dev/./urandom
71106
ports:
@@ -74,11 +109,15 @@ services:
74109
admin-server:
75110
image: springcommunity/spring-petclinic-admin-server
76111
container_name: admin-server
77-
mem_limit: 512M
112+
deploy:
113+
resources:
114+
limits:
115+
memory: 512M
78116
depends_on:
79-
- config-server
80-
- discovery-server
81-
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
117+
config-server:
118+
condition: service_healthy
119+
discovery-server:
120+
condition: service_healthy
82121
ports:
83122
- 9090:9090
84123

@@ -87,13 +126,19 @@ services:
87126
grafana-server:
88127
build: ./docker/grafana
89128
container_name: grafana-server
90-
mem_limit: 256M
129+
deploy:
130+
resources:
131+
limits:
132+
memory: 256M
91133
ports:
92134
- 3000:3000
93135

94136
prometheus-server:
95137
build: ./docker/prometheus
96138
container_name: prometheus-server
97-
mem_limit: 256M
139+
deploy:
140+
resources:
141+
limits:
142+
memory: 256M
98143
ports:
99144
- 9091:9090

docker/Dockerfile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@ ARG ARTIFACT_NAME
44
COPY ${ARTIFACT_NAME}.jar application.jar
55
RUN java -Djarmode=layertools -jar application.jar extract
66

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

148
FROM eclipse-temurin:17
15-
169
WORKDIR application
1710

18-
# Dockerize
19-
COPY --from=builder application/dockerize ./
20-
2111
ARG EXPOSED_PORT
2212
EXPOSE ${EXPOSED_PORT}
2313

pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
<docker.image.prefix>springcommunity</docker.image.prefix>
4040
<docker.image.exposed.port>9090</docker.image.exposed.port>
4141
<docker.image.dockerfile.dir>${basedir}</docker.image.dockerfile.dir>
42-
<docker.image.dockerize.version>v0.6.1</docker.image.dockerize.version>
4342
<container.executable>docker</container.executable>
4443
</properties>
4544

@@ -153,8 +152,6 @@
153152
<argument>ARTIFACT_NAME=${project.build.finalName}</argument>
154153
<argument>--build-arg</argument>
155154
<argument>EXPOSED_PORT=${docker.image.exposed.port}</argument>
156-
<argument>--build-arg</argument>
157-
<argument>DOCKERIZE_VERSION=${docker.image.dockerize.version}</argument>
158155
<argument>-t</argument>
159156
<argument>${docker.image.prefix}/${project.artifactId}</argument>
160157
<argument>${project.build.directory}</argument>

0 commit comments

Comments
 (0)