Skip to content

Commit

Permalink
use distroless docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk committed Aug 29, 2024
1 parent 9038589 commit fc4c62c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM gcr.io/distroless/java21-debian12
WORKDIR /app
COPY build/install/* /
COPY build/libs/app-*.jar app.jar
ENV JAVA_OPTS="-Dlogback.configurationFile=logback.xml"
ENV TZ="Europe/Oslo"
EXPOSE 8080
USER nonroot
CMD ["docker-kotlin-gradle-ktor-postgres"]
CMD [ "app.jar" ]
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,38 @@ You can check which version you have installed using this command:
java -version
```

Make sure you have the Docker installed
You can check which version you have installed using this command:
``` bash
docker --version
```

Make sure you have the Docker-compose installed
You can check which version you have installed using this command:
``` bash
docker-compose --version
```

### Running the application locally

#### Building the application
To build locally and run the integration tests you can simply run
``` bash
./gradlew clean build installDist
./gradlew shadowJar
```
or on windows `gradlew.bat shadowJar`


#### Creating a docker image
Creating a docker image should be as simple as
``` bash
docker build -t docker-kotlin-gradle-ktor-postgres .
```

#### Running a docker image
``` bash
docker run -d --rm -it -p 8080:8080 -e "DATABASE_HOST_URL=db" docker-kotlin-gradle-ktor-postgres
```
or on windows `gradlew.bat clean build installDist`

#### Integrasion testing the application
### Running the postgresSql db from docker compose
Expand Down Expand Up @@ -75,17 +99,6 @@ run this command:
./gradlew wrapper --gradle-version latest
```

#### Creating a docker image
Creating a docker image should be as simple as
``` bash
docker build -t docker-kotlin-gradle-ktor-postgres .
```

#### Running a docker image
``` bash
docker run -d --rm -it -p 8080:8080 -e "DATABASE_HOST_URL=db" docker-kotlin-gradle-ktor-postgres
```

### Contribute
Want to add a feature? see [CONTRIBUTING](CONTRIBUTING.md)

Expand Down
15 changes: 15 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
id("application")
kotlin("jvm") version "2.0.20"
id("com.diffplug.spotless") version "6.25.0"
id("com.gradleup.shadow") version "8.3.0"
}

application {
Expand Down Expand Up @@ -82,6 +83,20 @@ kotlin {
}

tasks {

shadowJar {
archiveBaseName.set("app")
archiveClassifier.set("")
isZip64 = true
manifest {
attributes(
mapOf(
"Main-Class" to "io.github.mikaojk.ApplicationKt",
),
)
}
}

test {
useJUnitPlatform {}
testLogging {
Expand Down

0 comments on commit fc4c62c

Please sign in to comment.