From d1af98e1095853e21792b879887545b3ddcbd186 Mon Sep 17 00:00:00 2001 From: minjoon-98 <4kmj54321@gmail.com> Date: Mon, 22 Jul 2024 08:42:57 +0900 Subject: [PATCH] fix: Fix issues with integrating Firebase config file in Docker image --- .github/workflows/Spring Boot CI-CD.yml | 12 ++++++------ Dockerfile | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Spring Boot CI-CD.yml b/.github/workflows/Spring Boot CI-CD.yml index 2b5adac..e662788 100644 --- a/.github/workflows/Spring Boot CI-CD.yml +++ b/.github/workflows/Spring Boot CI-CD.yml @@ -40,6 +40,10 @@ jobs: - name: Build with Gradle without test run: ./gradlew clean build --exclude-task test + # Save Firebase Admin SDK Key to File + - name: Save Firebase Admin SDK Key to File + run: echo '${{ secrets.FIREBASE_ADMINSDK_JSON }}' > src/main/resources/mooluck-fcm-firebase-adminsdk.json + # Docker Buildx 설정 - name: Docker Setup Buildx uses: docker/setup-buildx-action@v3.3.0 @@ -51,10 +55,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - # firebase.json file 생성 - - name: Create firebase.json file - run: echo '${{ secrets.FIREBASE_ADMINSDK_JSON }}' > /tmp/firebase-config.json - # 이미지 이름을 날짜와 함께 설정 - name: Set image name with date run: echo "IMAGE_NAME=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}:$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV @@ -62,7 +62,7 @@ jobs: # Docker 이미지 빌드 및 푸시 - name: Build and push Docker image run: | - docker build . -t ${{ env.IMAGE_NAME }} --build-arg FIREBASE_CONFIG_FILE=/tmp/firebase-config.json + docker build . -t ${{ env.IMAGE_NAME }} --build-arg FIREBASE_CONFIG_FILE=src/main/resources/mooluck-fcm-firebase-adminsdk.json docker push ${{ env.IMAGE_NAME }} # docker build . --file Dockerfile -t ${{ env.IMAGE_NAME }} @@ -129,7 +129,7 @@ jobs: -e OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY }}" \ -e FFMPEG_PATH="${{ secrets.FFMPEG_PATH }}" \ -e FFPROBE_PATH="${{ secrets.FFPROBE_PATH }}" \ - -e FIREBASE_CONFIG_PATH="/app/firebase-config.json" \ + -e FIREBASE_CONFIG_PATH="/app/mooluck-fcm-firebase-adminsdk.json" \ ${{ env.IMAGE_NAME }} sudo docker ps -a sudo docker system prune -f diff --git a/Dockerfile b/Dockerfile index 8620a86..690e6f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ # jdk17 Image Start FROM openjdk:17-slim -# 인자 설정 - JAR_FILE +# 인자 설정 - JAR_FILE 및 FIREBASE_CONFIG_FILE ARG JAR_FILE=build/libs/*.jar +ARG FIREBASE_CONFIG_FILE=src/main/resources/mooluck-fcm-firebase-adminsdk.json # jar File Copy COPY ${JAR_FILE} mooluck-spring.jar -# Firebase Config Copy -COPY ${FIREBASE_CONFIG_FILE} /app/firebase-config.json +# Firebase 설정 파일을 컨테이너의 특정 위치로 복사 +COPY ${FIREBASE_CONFIG_FILE} /app/mooluck-fcm-firebase-adminsdk.json # 필요한 패키지 설치 RUN apt-get update && apt-get install -y ffmpeg @@ -18,4 +19,4 @@ ENV FFMPEG_PATH=/usr/bin/ffmpeg ENV FFPROBE_PATH=/usr/bin/ffprobe # 기본 프로파일 실행 명령어 -ENTRYPOINT ["java", "-Dfirebase.config.path=/app/firebase-config.json", "-jar", "mooluck-spring.jar", "-Dspring.profiles.active=docker", "-Duser.timezone=Asia/Seoul"] +ENTRYPOINT ["java", "-Dfirebase.config.path=/app/mooluck-fcm-firebase-adminsdk.json", "-Dspring.profiles.active=docker", "-Duser.timezone=Asia/Seoul", "-jar", "mooluck-spring.jar"]