Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CourseHubApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.hackyourfuture.coursehub;

import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -10,13 +11,11 @@
@Configuration
public class SwaggerBehindReverseProxyConfig {

@Value("${open-api.suffix:#{environment.OPEN_API_SUFFIX}}")
private String openApiSuffix;

@Bean
ServerBaseUrlCustomizer serverBaseUrlCustomizer() {
return (serverBaseUrl, request) -> {
if (serverBaseUrl.contains("coursehub.hyf.dev")) {
return serverBaseUrl + "/api";
}
return serverBaseUrl;
};
return (serverBaseUrl, request) -> serverBaseUrl + openApiSuffix;
}
}
7 changes: 6 additions & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ server.port=8080

# Session in Redis Configuration
# We want users to stay logged in for 7 days for convenience
spring.session.timeout=7d
spring.session.timeout=7d

open-api.suffix=/api

springdoc.swagger-ui.url=${open-api.suffix}/v3/api-docs
springdoc.swagger-ui.config-url=${open-api.suffix}/v3/api-docs/swagger-config
18 changes: 18 additions & 0 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@ cd /opt/course-hub
docker compose down
docker compose up -d
```

### Operations

SSH into the server:
```bash
ssh user@server
cd /opt/course-hub
```

Docker status
```bash
docker stats
```

Checking logs:
```bash
docker compose logs -f <container-name>
```
15 changes: 14 additions & 1 deletion deployment/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ services:
nginx:
image: nginx:latest
container_name: nginx
restart: on-failure
ports:
- "443:443"
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- ./certificates:/etc/nginx/certificates
depends_on:
course-hub-backend:
condition: service_started
course-hub-frontend:
condition: service_started
# Postgres, main data store used by course-hub-backend
postgres:
image: postgres:18
container_name: postgres
restart: on-failure
environment:
POSTGRES_USER: course_user
POSTGRES_PASSWORD: course_user_password
Expand All @@ -27,25 +34,29 @@ services:
redis:
image: redis:7
container_name: redis
restart: on-failure
volumes:
- redis:/data
ports:
- "6379:6379"
course-hub-frontend:
image: ghcr.io/hackyourfuture/course-hub-frontend:latest
container_name: course-hub-frontend
restart: on-failure
environment:
BACKEND_URL: http://localhost/api
ports:
- "3000:3000"
course-hub-backend:
image: ghcr.io/hackyourfuture/course-hub-backend:latest
container_name: course-hub-backend
restart: on-failure
environment:
JVM_TOOL_OPTS: -XX:ReservedCodeCacheSize=80M
JVM_TOOL_OPTS: -XX:ReservedCodeCacheSize=120M
BPL_JVM_THREAD_COUNT: 20
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/coursehub
SPRING_DATA_REDIS_HOST: redis
OPEN_API_SUFFIX: /api
depends_on:
postgres:
condition: service_started
Expand All @@ -56,6 +67,8 @@ services:
# Agent that monitors whenever new versions of images are published and recreates the containers
watchtower:
image: containrrr/watchtower
container_name: watchtower
restart: on-failure
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 30
Expand Down
2 changes: 1 addition & 1 deletion frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80;
listen 3000;
server_name _;

root /usr/share/nginx/html;
Expand Down