Skip to content

Commit

Permalink
Modififed Dockerfile and Dockercompose
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-merlin committed Nov 18, 2024
1 parent b443d2d commit f30ea1e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
25 changes: 3 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
FROM gradle:7.6.1-jdk17-alpine AS build
FROM openjdk:17
WORKDIR /app
COPY . .
RUN gradle build -x test --no-daemon
COPY build/libs/*.jar app.jar

# Run stage
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app

# Create a non-root user
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring

# Copy the jar file from build stage
COPY --from=build /app/build/libs/*.jar app.jar

# Environment variables for database connection
ENV SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/blueprint
ENV SPRING_DATASOURCE_USERNAME=postgres
ENV SPRING_DATASOURCE_PASSWORD=postgres

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "app.jar"]
ENTRYPOINT ["java", "-jar", "app.jar"]
32 changes: 32 additions & 0 deletions docker-compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
services:
blueprint_admin_backend:
env_file: ".env"
build:
context: .
dockerfile: Dockerfile
environment:
- DATABASE_URL=jdbc:postgresql://postgres:5432/${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ports:
- '8080:8080'
depends_on:
- postgres

postgres:
env_file: ".env"
image: postgres:latest
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
logging:
options:
max-size: "10m"
max-file: "3"
ports:
- '5432:5432'
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./initdb_prod:/docker-entrypoint-initdb.d
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
postgres:
image: postgres:10.5
image: postgres:latest
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ spring.jpa.hibernate.ddl-auto=update

spring.jpa.properties.hibernate.format_sql=true

spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=blueprint_admin_backend
spring.datasource.password=postgres
spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/postgres}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:blueprint_admin_backend}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres}

spring.profiles.active=${SPRING_PROFILES_ACTIVE:dev}

blueprint_yaml.api.baseurl = https://auth.api.sitblueprint.com/api/v1

0 comments on commit f30ea1e

Please sign in to comment.