Skip to content

Commit 08c10c8

Browse files
author
Walid Baroudi
committed
Fix Dockerfiles for Microservices
1 parent 89829ef commit 08c10c8

File tree

14 files changed

+49
-22
lines changed

14 files changed

+49
-22
lines changed

.env.dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ LANGSMITH_PROJECT=studymate
2727
# Grafana
2828
GF_SECURITY_ADMIN_USER=admin
2929
GF_SECURITY_ADMIN_PASSWORD=admin
30+
31+
# Client
32+
VITE_API_BASE_URL=http://localhost:8083

client/src/lib/api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// API service for communicating with the microservices backend
2-
const API_BASE_URL = (import.meta as any).env?.VITE_API_BASE_URL ||
3-
(typeof window !== 'undefined' ? window.location.origin : 'http://localhost');
2+
const API_BASE_URL = (import.meta as any).env?.VITE_API_BASE_URL || 'http://localhost:8099';
43

54
// Common status type used throughout the application
65
// Aligned with backend DocumentStatus enum - backend uses PROCESSED as final ready state

docker-compose.dev.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
dockerfile: Dockerfile
66
ports:
77
- "3000:80"
8+
env_file: .env.dev
89
depends_on:
910
- auth-service
1011
networks:
@@ -18,6 +19,10 @@ services:
1819
- "8083:8083"
1920
restart: unless-stopped
2021
env_file: .env.dev
22+
depends_on:
23+
- postgres
24+
networks:
25+
- dev-network
2126

2227
document-service:
2328
build:
@@ -27,6 +32,10 @@ services:
2732
- "8084:8084"
2833
restart: unless-stopped
2934
env_file: .env.dev
35+
depends_on:
36+
- postgres
37+
networks:
38+
- dev-network
3039

3140
genai-service:
3241
build:
@@ -38,6 +47,8 @@ services:
3847
env_file: .env.dev
3948
depends_on:
4049
- genai
50+
networks:
51+
- dev-network
4152

4253
genai:
4354
build:
@@ -49,6 +60,8 @@ services:
4960
env_file: .env.dev
5061
depends_on:
5162
- weaviate
63+
networks:
64+
- dev-network
5265

5366
postgres:
5467
image: postgres:15

docker-compose.yml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ services:
2121
restart: unless-stopped
2222
networks:
2323
- proxy
24+
environment:
25+
- VITE_API_BASE_URL=https://studymate-tum.xyz
2426
labels:
2527
- "traefik.enable=true"
2628
- "traefik.http.routers.client.rule=Host(`studymate-tum.xyz`)"
@@ -42,7 +44,7 @@ services:
4244
- "traefik.http.services.auth.loadbalancer.server.port=8083"
4345
environment:
4446
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/auth_db
45-
- SPRING_DATASOURCE_USERNAME=postgres
47+
- SPRING_DATASOURCE_USERNAME=postgres # TODO: replace with env variable
4648
- SPRING_DATASOURCE_PASSWORD=postgres
4749
depends_on:
4850
- postgres

server/auth-service/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ WORKDIR /app
77
COPY gradlew .
88
COPY gradle gradle/
99
COPY build.gradle.kts .
10+
COPY settings.gradle.kts .
1011

1112
# Copy source code
1213
COPY src src/
1314

14-
# Make gradlew executable and build the application
15-
RUN chmod +x gradlew && ./gradlew build -x test --no-daemon
15+
# Fix line endings, make executable, and build
16+
RUN sed -i 's/\r$//' gradlew && \
17+
chmod +x gradlew && \
18+
./gradlew build -x test --no-daemon
1619

1720
# Runtime stage
1821
FROM eclipse-temurin:21-jre
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "auth-service"

server/auth-service/src/main/kotlin/de/tum/cit/aet/auth/config/SecurityConfig.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException
1616
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
1717
import org.springframework.security.crypto.password.PasswordEncoder
1818
import org.springframework.security.web.SecurityFilterChain
19-
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
2019
import org.springframework.web.cors.CorsConfiguration
2120
import org.springframework.web.cors.CorsConfigurationSource
2221
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
2322

2423
@Configuration
2524
@EnableWebSecurity
2625
@EnableMethodSecurity
27-
class SecurityConfig(
28-
private val jwtAuthenticationFilter: JwtAuthenticationFilter
29-
) {
26+
class SecurityConfig {
3027

3128
@Bean
3229
fun securityFilterChain(http: HttpSecurity, authenticationProvider: AuthenticationProvider): SecurityFilterChain {
@@ -42,7 +39,6 @@ class SecurityConfig(
4239
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
4340
}
4441
.authenticationProvider(authenticationProvider)
45-
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter::class.java)
4642

4743
return http.build()
4844
}

server/auth-service/src/main/resources/application.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
server.port=8083
33

44
# Database configuration
5-
spring.datasource.url=jdbc:postgresql://postgres:5432/auth_db
6-
spring.datasource.username=postgres
7-
spring.datasource.password=postgres
5+
spring.datasource.url=${SPRING_DATASOURCE_URL_AUTH:jdbc:postgresql://localhost:5432/auth_db}
6+
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres}
7+
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres}
88
spring.datasource.driver-class-name=org.postgresql.Driver
99

1010
# JPA configuration

server/document-service/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ WORKDIR /app
77
COPY gradlew .
88
COPY gradle gradle/
99
COPY build.gradle.kts .
10+
COPY settings.gradle.kts .
1011

1112
# Copy source code
1213
COPY src src/
1314

14-
# Make gradlew executable and build the application
15-
RUN chmod +x gradlew && ./gradlew build -x test --no-daemon
15+
# Fix line endings, make executable, and build
16+
RUN sed -i 's/\r$//' gradlew && \
17+
chmod +x gradlew && \
18+
./gradlew build -x test --no-daemon
1619

1720
# Runtime stage
1821
FROM eclipse-temurin:21-jre
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "document-service"

0 commit comments

Comments
 (0)