Skip to content

Commit 2df5d2b

Browse files
committed
feat: adding curl to distrolles image
1 parent 4ada4b8 commit 2df5d2b

4 files changed

+44
-0
lines changed

Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Stage 1: Use debian to install curl and gather its dependencies
2+
FROM debian:11-slim AS curl-deps
3+
RUN apt-get update && apt-get install -y curl
4+
RUN mkdir -p /tmp/curl-deps
5+
RUN cp $(ldd /usr/bin/curl | grep -v linux-vdso.so.1 | awk '{print $3}' | grep -v '^$') /tmp/curl-deps/
6+
RUN cp /usr/bin/curl /tmp/curl-deps/
7+
8+
# Stage 2: Final distroless image
9+
FROM gcr.io/distroless/java17-debian11
10+
COPY --from=curl-deps /tmp/curl-deps/* /usr/lib/
11+
COPY --from=curl-deps /usr/bin/curl /usr/bin/
12+
13+
# Configure the application
14+
EXPOSE 8080
15+
ENV JAVA_TOOL_OPTIONS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75"
16+
COPY build/libs/app.jar /app/app.jar
17+
WORKDIR /app
18+
CMD ["app.jar"]

build.gradle.kts

+13
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ tasks.javadoc {
212212
}
213213
}
214214

215+
// Original Jib configuration (commented out in favor of custom Dockerfile with curl)
216+
/*
215217
jib {
216218
from {
217219
platforms {
@@ -231,6 +233,17 @@ jib {
231233
mainClass = mainClassKt
232234
}
233235
}
236+
*/
237+
238+
// Add Docker build task for custom Dockerfile
239+
tasks.register("buildDocker") {
240+
dependsOn("shadowJar")
241+
doLast {
242+
exec {
243+
commandLine("docker", "build", "-t", "mock-oauth2-server:latest", ".")
244+
}
245+
}
246+
}
234247

235248
(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
236249
skip()

docker-compose-ssl.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ version: "3.1"
33
services:
44
mock-oauth2-server:
55
image: mock-oauth2-server:latest
6+
healthcheck:
7+
test: ["CMD", "curl", "--retry", "7", "--retry-delay", "1", "--retry-connrefused", "-sk", "-f", "https://localhost:8080/isalive"]
8+
interval: 10s
9+
timeout: 5s
10+
retries: 3
11+
start_period: 5s
612
ports:
713
- "8080:8080"
814
volumes:
@@ -11,3 +17,4 @@ services:
1117
LOG_LEVEL: "debug"
1218
SERVER_PORT: 8080
1319
JSON_CONFIG_PATH: /app/config.json
20+

docker-compose.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ version: "3.1"
33
services:
44
mock-oauth2-server:
55
image: mock-oauth2-server:latest
6+
healthcheck:
7+
test: ["CMD", "curl", "--retry", "7", "--retry-delay", "1", "--retry-connrefused", "-f", "http://localhost:8080/isalive"]
8+
interval: 10s
9+
timeout: 5s
10+
retries: 3
11+
start_period: 5s
612
ports:
713
- "8080:8080"
814
volumes:

0 commit comments

Comments
 (0)