Skip to content
Closed
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
27 changes: 26 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
services:
postgres:
image: postgres:16
restart: unless-stopped
environment:
POSTGRES_DB: codenames
POSTGRES_USER: codenames_user
POSTGRES_PASSWORD: codenames_pass
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U codenames_user -d codenames"]
interval: 10s
timeout: 5s
retries: 5

backend:
image: ghcr.io/ss26-se2-codenames/backend:latest
restart: unless-stopped
ports:
- "53213:8080"
volumes:
- ./data:/app/data
- ./data:/app/data
environment: # Inject datasource url into application.yml when containerized
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/codenames
SPRING_DATASOURCE_USERNAME: codenames_user
SPRING_DATASOURCE_PASSWORD: codenames_pass
depends_on:
postgres:
condition: service_healthy

volumes:
postgres_data:
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@
<artifactId>jspecify</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,23 @@ spring:
application:
name: Codenames_Backend

datasource:
url: jdbc:postgresql://localhost:5432/codenames # When we containerize docker compose will change localhost -> postgresql
username: codenames_user
password: codenames_pass
driver-class-name: org.postgresql.Driver

jpa:
hibernate:
ddl-auto: validate
show-sql: true
properties:
hibernate:
format_sql: true
dialect: org.hibernate.dialect.PostgreSQLDialect

flyway:
enabled: true

app:
allowed-origins: "http://localhost:8080,http://10.0.2.2:8080"
11 changes: 11 additions & 0 deletions src/test/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
spring:
datasource:
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=PostgreSQL # create mock h2 DB in RAM that doesn't close until tests finish
driver-class-name: org.h2.Driver
username: sa
password:
jpa:
hibernate:
ddl-auto: create-drop # flyway disabled, hibernate needs to take over and drop tables after test
flyway:
enabled: false # H2 might not work with flyway
Loading