Код: Выделить всё
org.springframework.boot
spring-boot-docker-compose
runtime
true
dockerfile
Код: Выделить всё
# Use the Amazon Corretto 21 base image
FROM amazoncorretto:21.0.3
# Create a volume for temporary files
VOLUME /tmp
# Arguments for the JAR file to be copied
ARG JAR_FILE=target/*.jar
EXPOSE 8080
EXPOSE 5432
# Copy the JAR file into the Docker image
COPY ${JAR_FILE} /app.jar
# Set the entry point for the container to run the application
ENTRYPOINT ["java","-jar","/app.jar"]
Код: Выделить всё
version: '3.8'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8081:8080"
environment:
SPRING_PROFILES_ACTIVE: dev
network_mode: host
postgres:
image: postgres:latest
restart: on-failure
environment:
- POSTGRES_DB=expiry_service_db
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
ports:
- "5431:5432"
network_mode: host
Код: Выделить всё
spring.application.name=expiry-service
server.port=8080
# expiry_service datasource
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/expiry_service_db
spring.datasource.username=postgres
spring.datasource.password=postgres
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.database-platform=postgres
spring.jpa.hibernate.ddl-auto=update
< /code>
Когда я запускаю приложение Spring Boot, он запускается на порте 8080: < /p>
Tomcat started on port 8080 (http) with context path '/expiry-service'
Подробнее здесь: https://stackoverflow.com/questions/785 ... ith-docker