Skip to content

Commit

Permalink
chore: Added firebase config path environment variable to Docker entr…
Browse files Browse the repository at this point in the history
…ypoint
  • Loading branch information
minjoon-98 committed Jul 21, 2024
1 parent aaafba9 commit 0d943f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ ENV FFMPEG_PATH=/usr/bin/ffmpeg
ENV FFPROBE_PATH=/usr/bin/ffprobe

# 기본 프로파일 실행 명령어
ENTRYPOINT ["java", "-jar", "mooluck-spring.jar", "-Dspring.profiles.active=docker", "-Duser.timezone=Asia/Seoul"]
ENTRYPOINT ["java", "-Dfirebase.config.path=/app/mooluck-fcm-firebase-adminsdk.json", "-jar", "mooluck-spring.jar", "-Dspring.profiles.active=docker", "-Duser.timezone=Asia/Seoul"]
14 changes: 8 additions & 6 deletions src/main/java/ongjong/namanmoo/config/FirebaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

@Configuration
public class FirebaseConfig {

@Value("${firebase.config.path}")
private String firebaseConfigPath;

@Bean
public FirebaseApp initializeFirebase() throws IOException {
// FirebaseApp 인스턴스가 이미 존재하는지 확인
if (FirebaseApp.getApps().isEmpty()) {
InputStream serviceAccount = getClass().getClassLoader().getResourceAsStream(firebaseConfigPath);

if (serviceAccount == null) {
throw new RuntimeException("Firebase config file not found" + firebaseConfigPath);
InputStream serviceAccount;
try {
serviceAccount = new FileInputStream(firebaseConfigPath);
} catch (Exception e) {
throw new IOException("Could not open Firebase config file: " + firebaseConfigPath);
}

FirebaseOptions options = new FirebaseOptions.Builder()
Expand All @@ -33,4 +35,4 @@ public FirebaseApp initializeFirebase() throws IOException {
}
return FirebaseApp.getInstance();
}
}
}

0 comments on commit 0d943f9

Please sign in to comment.