Skip to content

Commit

Permalink
feat: add Dockerfile and local docker compose example (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: ablandel <[email protected]>
  • Loading branch information
ablandel committed May 3, 2024
1 parent cf37950 commit 0b34233
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build inspired by https://zwbetz.com/why-is-my-gradle-build-in-docker-so-slow/ article.
FROM gradle:8.7.0-jdk21 AS build
WORKDIR /home/gradle/src
# Only copy dependency-related files.
COPY build.gradle.kts gradle.properties settings.gradle.kts ./
# Only download dependencies. The dependencies will be cached for next builds.
# Eat the expected build failure since no source code has been copied yet.
RUN gradle clean build --no-daemon > /dev/null 2>&1 || true
# Copy project sources.
COPY ./src ./src
# Do the real build without the unit tests (Docker would be required for DAOs tests).
RUN gradle bootJar -x test --no-daemon

FROM eclipse-temurin:21-jre
WORKDIR /app
EXPOSE 8080
COPY --from=build /home/gradle/src/build/libs/another-kaomoji-*.jar another-kaomoji.jar
ENTRYPOINT ["java", "-jar", "/app/another-kaomoji.jar"]
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Apr 02 18:24:22 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 24 additions & 0 deletions local.docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
postgresql:
container_name: another-kaomoji-db
image: postgres:16-alpine
restart: always
environment:
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
another-kaomoji:
container_name: another-kaomoji
image: another-kaomoji:local
restart: always
depends_on:
- postgresql
environment:
spring.datasource.url: jdbc:postgresql://postgresql:5432/postgres
ports:
- "8080:8080"

0 comments on commit 0b34233

Please sign in to comment.