diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..89bd560 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,28 @@ +name: Deploy Doddle Frontend + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: self-hosted + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build and tag Docker image + run: | + docker build --no-cache --build-arg API_DOMAIN=${{ secrets.API_DOMAIN_DEPLOY }} -t fe_deploy . + docker tag fe_deploy fe_deploy:latest + + - name: Deploy container locally + run: | + IMAGE=fe_deploy:latest + docker stop FE_DEPLOY || true + docker rm FE_DEPLOY || true + docker run -d --name FE_DEPLOY -p 25120:80 $IMAGE + docker system prune -af diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml new file mode 100644 index 0000000..4620bf0 --- /dev/null +++ b/.github/workflows/dev.yaml @@ -0,0 +1,28 @@ +name: DEV Deploy Doddle Frontend + +on: + push: + branches: + - dev + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: self-hosted + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build and tag Docker image + run: | + docker build --no-cache --build-arg API_DOMAIN=${{ secrets.API_DOMAIN_DEV }} -t fe_dev . + docker tag fe_dev fe_dev:latest + + - name: Deploy container locally + run: | + IMAGE=fe_dev:latest + docker stop FE_DEV || true + docker rm FE_DEV || true + docker run -d --name FE_DEV -p 25119:80 $IMAGE + docker system prune -af diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml deleted file mode 100644 index c6adab1..0000000 --- a/.github/workflows/docker-image.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build and Deploy Docker Image - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - build-and-deploy: - runs-on: self-hosted # 로컬 Ubuntu의 actions 계정에서 실행됨 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Build and tag Docker image - run: | - docker build --no-cache -t ${{ secrets.DOCKER_HUB_USERNAME }}/kws_fe:latest . - docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/kws_fe:latest ${{ secrets.DOCKER_HUB_USERNAME }}/kws_fe:latest - - - name: Deploy container locally - run: | - IMAGE=${{ secrets.DOCKER_HUB_USERNAME }}/kws_fe:latest - docker stop KWS_FE || true - docker rm KWS_FE || true - docker run -d --name KWS_FE -p 25120:80 $IMAGE - docker system prune -af diff --git a/Dockerfile b/Dockerfile index 88fdd8e..72a103c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,9 @@ WORKDIR /app COPY package*.json ./ RUN npm install --legacy-peer-deps +ARG API_DOMAIN +ENV VITE_API_DOMAIN=${API_DOMAIN} + # 애플리케이션 코드 복사 및 빌드 COPY . . RUN npm run build diff --git a/src/services/api.ts b/src/services/api.ts index 417d458..4d85be2 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -1,8 +1,10 @@ import axios from "axios"; import Cookies from "js-cookie"; +const API_DOMAIN = import.meta.env.VITE_API_DOMAIN; + const axiosClient = axios.create({ - baseURL: "https://doddle.kr/api", + baseURL: `https://${API_DOMAIN}/api`, headers: { "Content-Type": "application/json", },