Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Dockerfile and local docker compose example #4

Merged
merged 1 commit into from
May 3, 2024
Merged
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 @@
# 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"
Loading