Skip to content

Commit b823a7c

Browse files
committed
Adding configuration to build and push docker image, and make it easy to get up and running locally.
1 parent dcab167 commit b823a7c

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!target/*-with-dependencies.jar

.github/workflows/maven.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
1925
- name: Set up JDK
2026
uses: actions/setup-java@v4
2127
with:
@@ -36,3 +42,6 @@ jobs:
3642
path: target/*-jar-with-dependencies.jar
3743
if-no-files-found: error
3844
retention-days: 7
45+
46+
- name: Build and push docker image [edge]
47+
run: docker buildx build --push -t ghcr.io/javabin/moresleep:edge --platform linux/amd64,linux/arm64 .

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ target/
99
.mvn/
1010
src/main/kotlin/no/anksoft
1111
.DS_Store
12-
.env
12+
.env
13+
.postgres_data

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Fetch the application jar from the target directory and rename it to application.jar
2+
FROM amazoncorretto:21-al2023-headless AS fetch
3+
4+
COPY target /target
5+
RUN mv /target/*-with-dependencies.jar /target/application.jar
6+
7+
8+
# Actual image to run the application
9+
FROM amazoncorretto:21-al2023-headless
10+
11+
EXPOSE 8082
12+
ENV RUN_FROM_JAR=true
13+
14+
COPY --from=fetch /target/application.jar /work/application.jar
15+
16+
RUN java -jar /work/application.jar

docker-compose.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ name: moresleep
22

33
services:
44
db:
5-
build:
6-
context: docker/postgres
7-
dockerfile: Dockerfile
5+
build: docker/postgres
86
ports:
97
- "5432:5432"
8+
volumes:
9+
- .postgres_data:/var/lib/postgresql/data
10+
11+
service:
12+
image: amazoncorretto:21-al2023-headless
13+
command: java -jar /src/target/moresleep-0.0.1-jar-with-dependencies.jar
14+
ports:
15+
- "8082:8082"
16+
volumes:
17+
- ./:/src
18+
environment:
19+
- DBHOST=db
20+
- RUN_FROM_JAR=true
21+
env_file:
22+
- path: ./.env
23+
required: false

docker/postgres/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
FROM postgres:12.4
2+
EXPOSE 5432
23
COPY postgressetup.sh /docker-entrypoint-initdb.d/init-user-db.sh
34
ENV POSTGRES_PASSWORD bingo

0 commit comments

Comments
 (0)