From 3d08485b5544889fa3ad1a73aa8a0140390c5ebf Mon Sep 17 00:00:00 2001
From: Lars Johansson <lars.johansson@ess.eu>
Date: Wed, 23 Feb 2022 20:57:17 +0100
Subject: [PATCH] Added dockerisation

---
 Dockerfile                                    | 10 +++++++
 docker-compose.yml                            | 29 +++++++++++++++++++
 .../resources/application-docker.properties   | 14 +++++++++
 src/main/resources/application.properties     | 14 +++++++++
 4 files changed, 67 insertions(+)
 create mode 100644 Dockerfile
 create mode 100644 docker-compose.yml
 create mode 100644 src/main/resources/application-docker.properties

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..55cad0b0
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,10 @@
+# ------------------------------------------------------------------------------
+# Copyright (C) 2021 European Spallation Source ERIC.
+# ------------------------------------------------------------------------------
+
+FROM openjdk:17
+
+# deployment unit
+COPY target/naming-backend-0.0.1-SNAPSHOT.jar /naming/naming-backend-0.0.1-SNAPSHOT.jar
+
+CMD ["java", "-jar", "/naming/naming-backend-0.0.1-SNAPSHOT.jar", "--spring.config.name=application-docker"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..423f76ba
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,29 @@
+# ------------------------------------------------------------------------------
+# Copyright (C) 2022 European Spallation Source ERIC.
+# ------------------------------------------------------------------------------
+
+version: '3.7'
+services:
+  naming:
+    build: ./
+    ports:
+      - "8080:8083"
+    depends_on:
+      - postgres
+    command: "java -jar /naming/naming-backend-0.0.1-SNAPSHOT.jar"
+  
+  postgres:
+    container_name: "postgres"
+    image: "postgres:9.6.7"
+    ports:
+      - "5432:5432"
+    environment:
+      POSTGRES_DB: discs_names
+      POSTGRES_USER: discs_names
+      POSTGRES_PASSWORD: discs_names
+      PGDATA: /var/lib/postgresql/data/pgdata
+    volumes:
+      - naming-data:/var/lib/postgresql/data/pgdata
+
+volumes:
+  naming-data:
diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties
new file mode 100644
index 00000000..f21cd215
--- /dev/null
+++ b/src/main/resources/application-docker.properties
@@ -0,0 +1,14 @@
+
+server.port=8083
+
+spring.profiles.active=@spring.profiles.active@
+
+# ------------------------------------------------------------
+
+spring.datasource.url=jdbc:postgresql://postgres:5432/discs_names
+spring.datasource.username=discs_names
+spring.datasource.password=discs_names
+
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+spring.jpa.hibernate.ddl-auto=none
+spring.jpa.hibernate.show-sql=true
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e69de29b..f21cd215 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -0,0 +1,14 @@
+
+server.port=8083
+
+spring.profiles.active=@spring.profiles.active@
+
+# ------------------------------------------------------------
+
+spring.datasource.url=jdbc:postgresql://postgres:5432/discs_names
+spring.datasource.username=discs_names
+spring.datasource.password=discs_names
+
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+spring.jpa.hibernate.ddl-auto=none
+spring.jpa.hibernate.show-sql=true
-- 
GitLab