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

🐛 [HotFix] Fix docker-cd.yml #614

Merged
merged 16 commits into from
Aug 22, 2023
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
54 changes: 35 additions & 19 deletions .github/workflows/docker-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,53 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push backend Docker image
run: |
cd backend
docker build -t ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest
uses: docker/build-push-action@v4
with:
context: .
file: ./backend/Dockerfile
platforms: linux/amd64, linux/arm64/v8
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest

- name: Build and push frontend Docker image
run: |
cd frontend
docker build -t ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest
uses: docker/build-push-action@v4
with:
context: .
file: ./frontend/Dockerfile
platforms: linux/amd64,linux/arm64/v8
build-args: |
VITE_BASE_URL=${{ secrets.VITE_BASE_URL }}
VITE_API_URL=${{ secrets.VITE_BASE_URL }}/api/v1
VITE_ASSET_URL=${{ secrets.VITE_BASE_URL }}
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest

deploy-to-ec2:
runs-on: ubuntu-latest
needs: build-and-push

steps:
- name: Deploy to Server
run: |
ssh-keyscan ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
echo "${{ secrets.SERVER_SSH_KEY }}" > ${{ secrets.EC2_KEY }}
chmod 600 ${{ secrets.EC2_KEY }}
scp docker-compose.yml ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:~/docker-compose.yml
ssh -i ${{ secrets.EC2_KEY }} ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'ENDSSH'
docker pull ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest
docker compose -f ~/docker-compose.yml down
docker compose -f ~/docker-compose.yml up -d
ENDSSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
envs: GITHUB_SHA
script: |
sudo docker ps
sudo docker compose -f ~/docker-compose.yml down && \
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest && \
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest && \
sudo docker compose -f ~/docker-compose.yml up -d
sudo docker image prune -f
9 changes: 8 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ FROM node:18-alpine AS builder

WORKDIR /app/frontend

ARG VITE_BASE_URL
ARG VITE_API_URL
ARG VITE_ASSET_URL

ENV VITE_BASE_URL=$VITE_BASE_URL
ENV VITE_API_URL=$VITE_API_URL
ENV VITE_ASSET_URL=$VITE_ASSET_URL

COPY ./frontend /app/frontend

COPY ./game /app/game
Expand All @@ -17,4 +25,3 @@ COPY --from=builder /app/frontend/dist /app/dist
COPY ./frontend/nginx.conf /etc/nginx/conf.d/default.conf

ENTRYPOINT ["nginx", "-g", "daemon off;"]

2 changes: 1 addition & 1 deletion frontend/src/pages/MessagePage/BlockModal/BlockModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const BlockModal = ({ isOpen, onClose }: Omit<ModalProps, 'children'>) =>
<GameInput
value={nickname}
onChange={handleNicknameChange}
sizes="sm"
sizes="lg"
color="secondary"
placeholder="플레이어 닉네임"
style={{ flexGrow: 1 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const FriendsModal = ({ isOpen, onClose }: Omit<ModalProps, 'children'>)
<GameInput
value={nickname}
onChange={handleNicknameChange}
sizes="sm"
sizes="lg"
color="secondary"
placeholder="플레이어 닉네임"
style={{ flexGrow: 1 }}
Expand Down