From 10bcf3ac308f45281026bd4b853c416fea3595fa Mon Sep 17 00:00:00 2001 From: lardira Date: Mon, 28 Oct 2024 15:18:52 +0300 Subject: [PATCH] dockerized --- .dockerfile | 0 Dockerfile | 12 +++++++++ compose.yaml | 30 +++++++++++++++++++++++ src/main/resources/application.properties | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) delete mode 100644 .dockerfile create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/.dockerfile b/.dockerfile deleted file mode 100644 index e69de29..0000000 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0c4f40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +ARG SRC_DIR=/home/app/konce + +FROM maven:3.9-eclipse-temurin-17-alpine AS build +WORKDIR $SRC_DIR +COPY src/main src/main +COPY pom.xml pom.xml +RUN mvn clean package + +FROM eclipse-temurin:17-alpine AS run +WORKDIR $SRC_DIR +COPY --from=build $SRC_DIR/target/*.jar build/app.jar +ENTRYPOINT ["java", "-jar", "./build/app.jar"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..0cc9a35 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,30 @@ +services: + api: + build: . + env_file: + - ".env" + depends_on: + - db + ports: + - "8080:8080" + networks: + - db-net + db: + image: "postgres:alpine" + environment: + - POSTGRES_USER=${DB_USERNAME} + - POSTGRES_PASSWORD=${DB_PASSWORD} + - POSTGRES_DB=konce + volumes: + - db-data:/var/lib/postgresql/data +# ports: +# - "5432:5432" + networks: + - db-net + +volumes: + db-data: + +networks: + db-net: + driver: bridge \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f094649..c3cdc74 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ # app spring.application.name=konce -spring.config.import=optional:file:.env[.properties] +spring.config.import=optional:file:local.env[.properties] # db spring.datasource.url=${DB_URL}