From 62bfbba1591230cbb6978c2d25fe84450f0ed776 Mon Sep 17 00:00:00 2001
From: jonycoo
Date: Wed, 3 May 2023 13:41:15 +0200
Subject: [PATCH] create Docker Postgres
---
Dockerfile | 13 ++++++++++
docker-compose.yml | 31 +++++++++++++++++++++++
src/main/resources/application.properties | 4 ++-
3 files changed, 47 insertions(+), 1 deletion(-)
create mode 100644 Dockerfile
create mode 100644 docker-compose.yml
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..68620b1
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,13 @@
+# syntax=docker/dockerfile:1
+
+# FROM eclipse-temurin:17-jdk-jammy
+
+# WORKDIR /spring-boot-jpa-postgresql
+
+# COPY .mvn/ .mvn
+# COPY mvnw pom.xml ./
+# RUN ./mvnw dependency:resolve
+
+# COPY src ./src
+
+# CMD ["./mvnw", "spring-boot:run"]
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..8bdc1f6
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,31 @@
+# A Docker Compose must always start with the version tag.
+# We use '3' because it's the last version.
+version: '3'
+
+# You should know that Docker Compose works with services.
+# 1 service = 1 container.
+# For example, a service, a server, a client, a database...
+# We use the keyword 'services' to start to create services.
+services:
+ # The name of our service is "database"
+ # but you can use the name of your choice.
+ # Note: This may change the commands you are going to use a little bit.
+ database:
+ # Official Postgres image from DockerHub (we use the last version)
+ image: 'postgres:latest'
+
+ # By default, a Postgres database is running on the 5432 port.
+ # If we want to access the database from our computer (outside the container),
+ # we must share the port with our computer's port.
+ # The syntax is [port we want on our machine]:[port we want to retrieve in the container]
+ # Note: You are free to change your computer's port,
+ # but take into consideration that it will change the way
+ # you are connecting to your database.
+ ports:
+ - 5432:5432
+
+ environment:
+ POSTGRES_USER: postgres # The PostgreSQL user (useful to connect to the database)
+ POSTGRES_PASSWORD: 123 # The PostgreSQL password (useful to connect to the database)
+ POSTGRES_DB: testdb # The PostgreSQL default database (automatically created at first launch)
+
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index d80abe8..32796fe 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -6,4 +6,6 @@ spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
-spring.jpa.hibernate.ddl-auto= update
\ No newline at end of file
+spring.jpa.hibernate.ddl-auto= update
+
+server.port=8080
\ No newline at end of file