Skip to content

Commit 60852ab

Browse files
Fix OpenAPI and frontend port, add restart policy (#4)
* Fix OpenAPI and frontend port, add restart policy * Update backend/src/main/java/net/hackyourfuture/coursehub/CourseHubApplication.java Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 1e7f4f7 commit 60852ab

File tree

6 files changed

+44
-10
lines changed

6 files changed

+44
-10
lines changed

backend/src/main/java/net/hackyourfuture/coursehub/CourseHubApplication.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5-
65
@SpringBootApplication
76
public class CourseHubApplication {
87

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.hackyourfuture.coursehub;
22

33
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
4+
import org.springframework.beans.factory.annotation.Value;
45
import org.springframework.context.annotation.Bean;
56
import org.springframework.context.annotation.Configuration;
67

@@ -10,13 +11,11 @@
1011
@Configuration
1112
public class SwaggerBehindReverseProxyConfig {
1213

14+
@Value("${open-api.suffix:#{environment.OPEN_API_SUFFIX}}")
15+
private String openApiSuffix;
16+
1317
@Bean
1418
ServerBaseUrlCustomizer serverBaseUrlCustomizer() {
15-
return (serverBaseUrl, request) -> {
16-
if (serverBaseUrl.contains("coursehub.hyf.dev")) {
17-
return serverBaseUrl + "/api";
18-
}
19-
return serverBaseUrl;
20-
};
19+
return (serverBaseUrl, request) -> serverBaseUrl + openApiSuffix;
2120
}
2221
}

backend/src/main/resources/application.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ server.port=8080
1111

1212
# Session in Redis Configuration
1313
# We want users to stay logged in for 7 days for convenience
14-
spring.session.timeout=7d
14+
spring.session.timeout=7d
15+
16+
open-api.suffix=/api
17+
18+
springdoc.swagger-ui.url=${open-api.suffix}/v3/api-docs
19+
springdoc.swagger-ui.config-url=${open-api.suffix}/v3/api-docs/swagger-config

deployment/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,21 @@ cd /opt/course-hub
1313
docker compose down
1414
docker compose up -d
1515
```
16+
17+
### Operations
18+
19+
SSH into the server:
20+
```bash
21+
ssh user@server
22+
cd /opt/course-hub
23+
```
24+
25+
Docker status
26+
```bash
27+
docker stats
28+
```
29+
30+
Checking logs:
31+
```bash
32+
docker compose logs -f <container-name>
33+
```

deployment/docker-compose.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ services:
55
nginx:
66
image: nginx:latest
77
container_name: nginx
8+
restart: on-failure
89
ports:
910
- "443:443"
1011
- "80:80"
1112
volumes:
1213
- ./nginx.conf:/etc/nginx/conf.d/default.conf
1314
- ./certificates:/etc/nginx/certificates
15+
depends_on:
16+
course-hub-backend:
17+
condition: service_started
18+
course-hub-frontend:
19+
condition: service_started
1420
# Postgres, main data store used by course-hub-backend
1521
postgres:
1622
image: postgres:18
1723
container_name: postgres
24+
restart: on-failure
1825
environment:
1926
POSTGRES_USER: course_user
2027
POSTGRES_PASSWORD: course_user_password
@@ -27,25 +34,29 @@ services:
2734
redis:
2835
image: redis:7
2936
container_name: redis
37+
restart: on-failure
3038
volumes:
3139
- redis:/data
3240
ports:
3341
- "6379:6379"
3442
course-hub-frontend:
3543
image: ghcr.io/hackyourfuture/course-hub-frontend:latest
3644
container_name: course-hub-frontend
45+
restart: on-failure
3746
environment:
3847
BACKEND_URL: https://coursehub.hyf.dev/api
3948
ports:
4049
- "3000:3000"
4150
course-hub-backend:
4251
image: ghcr.io/hackyourfuture/course-hub-backend:latest
4352
container_name: course-hub-backend
53+
restart: on-failure
4454
environment:
45-
JVM_TOOL_OPTS: -XX:ReservedCodeCacheSize=80M
55+
JVM_TOOL_OPTS: -XX:ReservedCodeCacheSize=120M
4656
BPL_JVM_THREAD_COUNT: 20
4757
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/coursehub
4858
SPRING_DATA_REDIS_HOST: redis
59+
OPEN_API_SUFFIX: /api
4960
depends_on:
5061
postgres:
5162
condition: service_started
@@ -56,6 +67,8 @@ services:
5667
# Agent that monitors whenever new versions of images are published and recreates the containers
5768
watchtower:
5869
image: containrrr/watchtower
70+
container_name: watchtower
71+
restart: on-failure
5972
volumes:
6073
- /var/run/docker.sock:/var/run/docker.sock
6174
command: --interval 30

frontend/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
server {
2-
listen 80;
2+
listen 3000;
33
server_name _;
44

55
root /usr/share/nginx/html;

0 commit comments

Comments
 (0)