Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create Docker Postgres #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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)

4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
spring.jpa.hibernate.ddl-auto= update

server.port=8080