Skip to content

Commit

Permalink
feat: add backend to docker compose file
Browse files Browse the repository at this point in the history
Issue #91

This change adds a new service to the docker-compose file for the
backend REST api. If you want to run the backend locally all you need is
to run at the project root folder: `docker compose up backend` and
you're all set.

Other minor changes were made:
- Add some properties to the application properties file
- Remove dependencies not required for now
  • Loading branch information
Ricardo Campos committed Sep 15, 2023
1 parent f837737 commit 13f2bb5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
50 changes: 27 additions & 23 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,42 +129,22 @@
<optional>true</optional>
</dependency>

<!-- Authentication and Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-authorization-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>

<!-- DevOps -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Database -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

<!-- Documentation -->
Expand Down Expand Up @@ -479,4 +459,28 @@
</plugins>
</build>

<!--
Issue:
- spring-boot-starter-oauth2-client (v3.1.1-latest) depends on
- spring-security-oauth2-client (v6.1.1-latest) depends on
- oauth2-oidc-sdk (v10.10.1-latest) depends on
- nimbus-jose-jwt (v9.30.2 NOT THE LATESTE)
conficts with:
- spring-boot-starter-oauth2-client (v3.1.1-latest) depends on
- spring-security-oauth2-jose (v6.1.1-latest) depends on
- nimbus-jose-jwt (v9.31 LATEST)
Forcing oauth2-oidc-sdk to update its dependency nimbus-jose-jwt to version 9.31
solves the issue, for now.
-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.31</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
10 changes: 10 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# General application
logging.level.ca.bc.gov.restapi.results = ${LOGGING_LEVEL:INFO}
spring.application.name = results-backend-api
server.error.include-message=always
server.port = ${SERVER_PORT:8080}

# Actuator and ops
management.endpoint.health.show-details = always

# Native Cloud
springdoc.enable-native-support = true
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ services:
ports: ["3005:3000"]
volumes: ["./frontend/Caddyfile:/etc/caddy/Caddyfile"]
<<: *common

backend:
container_name: backend
ports: ["8080:8080", "5005:5005"]
image: maven:3.9.3-eclipse-temurin-17
entrypoint: mvn -ntp spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005"
working_dir: /app
volumes: ["./backend:/app"]
healthcheck:
test: curl -f http://localhost:8080/actuator/health | grep '"status":"UP"'
interval: 5s
timeout: 5s
retries: 5

0 comments on commit 13f2bb5

Please sign in to comment.