chore(deployment): add deployment for backend #16

Merged
csimonis merged 5 commits from deployment/backend into main 2025-02-12 10:37:25 +00:00
3 changed files with 35 additions and 1 deletions
Showing only changes of commit 3113eee414 - Show all commits

View File

@ -0,0 +1,32 @@
# First stage: Build the application
FROM gradle:jdk22 AS builder
WORKDIR /app
# Copy only Gradle wrapper and configuration files first (for caching efficiency)
COPY gradlew build.gradle.kts settings.gradle.kts ./
COPY gradle gradle
# Give execute permissions to Gradle wrapper
RUN chmod +x gradlew
# Download dependencies first (improves caching)
RUN ./gradlew dependencies
# Copy the rest of the project files
COPY src src
# Build the application (skipping tests for faster build)
RUN ./gradlew clean build -x test
# Second stage: Run the application
FROM openjdk:22-jdk-slim
WORKDIR /app
# Copy the built JAR from the first stage
COPY --from=builder /app/build/libs/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

2
backend/.dockerignore Normal file
View File

@ -0,0 +1,2 @@
.gradle
build

View File

@ -1,4 +1,4 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/postgresdb spring.datasource.url=jdbc:postgresql://$DB_HOST}:5432/postgresdb
spring.datasource.username=postgres_user spring.datasource.username=postgres_user
spring.datasource.password=postgres_pass spring.datasource.password=postgres_pass
server.port=8080 server.port=8080