Skip to content

Commit

Permalink
chore: 도커 파일 배포 기본 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielyoon7 committed Aug 2, 2023
1 parent f837efb commit dc8941c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/frontend-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- release/frontend
- prod/frontend

jobs:
deploy:
Expand Down Expand Up @@ -45,9 +45,10 @@ jobs:
sudo docker pull woowacarffeine/frontend:latest
sudo docker run --rm -d -p 3000:3000 \
-e "YARN_PROFILE=--production" \
--name frontend \
woowacarffeine/frontend:latest
sudo docker image prune -f
- name: clean images
run: |
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/frontend-dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: deploy

on:
workflow_dispatch:
push:
branches:
- release/frontend

jobs:
deploy:
runs-on: self-hosted
steps:
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: actions/checkout@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: woowacarffeine/frontend-dev

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: woowacarffeine/frontend-dev:latest
labels: ${{ steps.meta.outputs.labels }}

- name: Join EC2 dev server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
port: ${{ secrets.SERVER_PORT }}

script: |
sudo docker stop frontend || true
sudo docker pull woowacarffeine/frontend-dev:latest
sudo docker run --rm -d -p 3001:3000 \
-e "YARN_PROFILE= " \
--name frontend \
woowacarffeine/frontend-dev:latest
sudo docker image prune -f
- name: clean images
run: |
docker image prune -f
4 changes: 3 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ WORKDIR /usr/src/app
COPY package.json package.json
COPY yarn.lock yarn.lock

RUN yarn --production
ENV YARN_PROFILE = ${YARN_PROFILE}

RUN yarn ${YARN_PROFILE}

COPY . .

Expand Down

0 comments on commit dc8941c

Please sign in to comment.