Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Stage 1: Use debian to install curl and gather its dependencies
FROM debian:11-slim AS curl-deps
RUN apt-get update && apt-get install -y curl
RUN mkdir -p /tmp/curl-deps
RUN cp $(ldd /usr/bin/curl | grep -v linux-vdso.so.1 | awk '{print $3}' | grep -v '^$') /tmp/curl-deps/
RUN cp /usr/bin/curl /tmp/curl-deps/

# Stage 2: Final distroless image
FROM gcr.io/distroless/java17-debian11
COPY --from=curl-deps /tmp/curl-deps/* /usr/lib/
COPY --from=curl-deps /usr/bin/curl /usr/bin/

# Configure the application
EXPOSE 8080
ENV JAVA_TOOL_OPTIONS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75"
COPY build/libs/app.jar /app/app.jar
WORKDIR /app
CMD ["app.jar"]
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ tasks.javadoc {
}
}

// Original Jib configuration (commented out in favor of custom Dockerfile with curl)
/*
jib {
from {
platforms {
Expand All @@ -214,6 +216,17 @@ jib {
mainClass = mainClassKt
}
}
*/

// Add Docker build task for custom Dockerfile
tasks.register("buildDocker") {
dependsOn("shadowJar")
doLast {
exec {
commandLine("docker", "build", "-t", "mock-oauth2-server:latest", ".")
}
}
}

(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
Expand Down
7 changes: 7 additions & 0 deletions docker-compose-ssl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ version: "3.1"
services:
mock-oauth2-server:
image: mock-oauth2-server:latest
healthcheck:
test: ["CMD", "curl", "--retry", "7", "--retry-delay", "1", "--retry-connrefused", "-sk", "-f", "https://localhost:8080/isalive"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
ports:
- "8080:8080"
volumes:
Expand All @@ -11,3 +17,4 @@ services:
LOG_LEVEL: "debug"
SERVER_PORT: 8080
JSON_CONFIG_PATH: /app/config.json

6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ version: "3.1"
services:
mock-oauth2-server:
image: mock-oauth2-server:latest
healthcheck:
test: ["CMD", "curl", "--retry", "7", "--retry-delay", "1", "--retry-connrefused", "-f", "http://localhost:8080/isalive"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
ports:
- "8080:8080"
volumes:
Expand Down