Skip to content

Commit 891c19d

Browse files
committed
prod: commit some prod changes
1 parent f46f834 commit 891c19d

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

.github/workflows/java-ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ jobs:
2222
--health-retries 5
2323
2424
env:
25-
MONGO_DB_HOST: localhost
26-
MONGO_DB_PORT: 27017
27-
DB_NAME: ${{ secrets.DB_NAME }}
25+
MONGO_URI: ${{ secrets.MONGO_URI }}
2826
MAIL_USERNAME: ${{ secrets.USERNAME }}
2927
MAIL_PASSWORD: ${{ secrets.PASSWORD }}
3028
JWT_SECRET: ${{ secrets.JWT_SECRET }}
31-
29+
FRONTEND_ORIGIN: ${{ secrets.FRONTEND_ORIGIN }}
3230

3331
steps:
3432
- name: Checkout Repository

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Building the JAR
2+
FROM maven:3.9.6-eclipse-temurin-17 AS builder
3+
WORKDIR /app
4+
COPY . .
5+
RUN mvn clean package -DskipTests
6+
7+
# Running the JAR
8+
FROM openjdk:17-jdk-slim
9+
WORKDIR /app
10+
COPY --from=builder /app/target/Connect-0.0.1-SNAPSHOT.jar connect-backend.jar
11+
EXPOSE 8080
12+
ENTRYPOINT ["java", "-jar", "connect-backend.jar"]

src/main/java/com/connect/config/SecurityConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.connect.config;
22

3+
import org.springframework.beans.factory.annotation.Value;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56
import org.springframework.http.HttpMethod;
@@ -24,6 +25,9 @@
2425
@EnableWebSocket
2526
public class SecurityConfig {
2627

28+
@Value("${frontend.origin}")
29+
private String FRONTEND_URL;
30+
2731
@Bean
2832
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
2933
return http
@@ -43,7 +47,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
4347
@Bean
4448
public CorsConfigurationSource corsConfigurationSource() {
4549
CorsConfiguration cors = new CorsConfiguration();
46-
cors.setAllowedOrigins(List.of("http://localhost:5500", "http://127.0.0.1:5500", "http://localhost:5173", "http://127.0.0.1:5173"));
50+
cors.setAllowedOrigins(List.of(FRONTEND_URL));
4751
cors.setAllowedMethods(List.of("GET", "PUT", "POST", "DELETE", "OPTIONS"));
4852
cors.setAllowedHeaders(List.of("*"));
4953
cors.setAllowCredentials(true);

src/main/java/com/connect/config/WebSocketConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.connect.service.JwtTokenService;
44
import com.connect.security.StompPrincipal;
55
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.beans.factory.annotation.Value;
67
import org.springframework.context.annotation.Configuration;
78
import org.springframework.messaging.Message;
89
import org.springframework.messaging.MessageChannel;
@@ -22,6 +23,9 @@
2223
@EnableWebSocketMessageBroker
2324
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
2425

26+
@Value("${frontend.origin}")
27+
private String FRONTEND_URL;
28+
2529
@Autowired
2630
private JwtTokenService service;
2731

@@ -36,7 +40,7 @@ public void configureMessageBroker(MessageBrokerRegistry config) {
3640
public void registerStompEndpoints(StompEndpointRegistry registry) {
3741
registry
3842
.addEndpoint("/ws")
39-
.setAllowedOrigins("http://127.0.0.1:5500", "http://localhost:5500", "http://localhost:5173", "http://127.0.0.1:5173")
43+
.setAllowedOrigins(FRONTEND_URL)
4044
.withSockJS();
4145
}
4246

src/main/resources/application.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
spring.application.name=Connect
2-
spring.data.mongodb.host=${MONGO_DB_HOST}
3-
spring.data.mongodb.port=${MONGO_DB_PORT}
4-
spring.data.mongodb.database=${DB_NAME}
2+
spring.data.mongodb.uri=${MONGO_URI}
53

64
spring.mail.host=smtp.gmail.com
75
spring.mail.port=465
@@ -16,4 +14,7 @@ spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
1614
jwt.secret.key=${JWT_SECRET}
1715

1816
# logging for cors issues and spring security
19-
logging.level.org.springframework.security=DEBUG
17+
logging.level.org.springframework.security=DEBUG
18+
19+
# Frontend origin
20+
frontend.origin = ${FRONTEND_ORIGIN}

0 commit comments

Comments
 (0)