setup prod deploy with db

This commit is contained in:
2025-10-23 19:26:21 +02:00
parent 3d20e876c3
commit 4a2838c208
3 changed files with 55 additions and 2 deletions

View File

@@ -1 +1,29 @@
# TODO
# Stage 1: Build stage
FROM maven:3.9-eclipse-temurin-21 AS build
# Set the working directory inside the container
WORKDIR /app
# Copy the pom.xml and dependencies (helps in caching dependencies)
COPY pom.xml .
# Download dependencies (this will cache dependencies in the Docker layer)
RUN mvn dependency:go-offline
# Copy the rest of the application source code
COPY src ./src
# Build the Spring Boot app
RUN mvn clean package
# Stage 2: Run stage
FROM eclipse-temurin:21-jdk AS runtime
# Copy the built JAR file from the build stage
COPY --from=build /app/target/*.jar /app/app.jar
# Expose the default Spring Boot port
EXPOSE 8080
# Command to run the Spring Boot application
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

View File

@@ -1 +1,22 @@
# TODO
services:
app:
build: .
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/mydb
SPRING_DATASOURCE_USERNAME: myuser
SPRING_DATASOURCE_PASSWORD: mypassword
SPRING_JPA_HIBERNATE_DDL_AUTO: update # Automatically create/update DB schema
depends_on:
- db
db:
image: postgres:15
environment:
POSTGRES_DB: mydb
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
ports:
- "5432:5432"

View File

@@ -33,6 +33,10 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>