Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨firebase CI/CD🚨 #100

Merged
merged 1 commit into from
Jul 21, 2024
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
12 changes: 6 additions & 6 deletions .github/workflows/Spring Boot CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -51,18 +55,14 @@ 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

# 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 }}

Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
Loading