diff --git a/.github/workflows/docker-deploy.yml b/.github/workflows/docker-deploy.yml index 7b50825..30b9c2d 100644 --- a/.github/workflows/docker-deploy.yml +++ b/.github/workflows/docker-deploy.yml @@ -13,36 +13,36 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' - - name: Install dependencies - run: npm install + - name: Install dependencies + run: npm install - - name: Build project - run: npm run build + - name: Build project + run: npm run build - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: Log in to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + - name: Log in to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/frontend-folio:latest - platforms: linux/amd64,linux/arm64 + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/frontend-folio:latest + platforms: linux/amd64,linux/arm64 deploy: runs-on: ubuntu-latest @@ -63,4 +63,4 @@ jobs: docker pull ${{ secrets.DOCKERHUB_USERNAME }}/frontend-folio:latest docker stop frontend-folio || true docker rm frontend-folio || true - docker run -d -p 80:3000 --name frontend-folio ${{ secrets.DOCKERHUB_USERNAME }}/frontend-folio:latest \ No newline at end of file + docker run -d -p 80:80 --name frontend-folio ${{ secrets.DOCKERHUB_USERNAME }}/frontend-folio:latest diff --git a/.vscode/settings.json b/.vscode/settings.json index e058556..252e9b3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.codeActionsOnSave": { - "source.fixAll.eslint": true // NOTE 그냥 True로 적게되면 어떤 수정 도구가 적용될지 명확하지 않음. + "source.fixAll.eslint": "explicit" }, "editor.formatOnSave":true, // 출처: https://ek12mv2.tistory.com/223 [Not only Slow but also Steady:티스토리] diff --git a/Dockerfile b/Dockerfile index 741acf1..0d86dd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ -# 운용할 배포 서버(랴즈)가 aarch64 플랫폼, Node.js의 경량 버전을 베이스 이미지로 사용합니다. +# Node.js의 경량 버전을 베이스 이미지로 사용합니다. FROM node:20-alpine +# Apache와 필요한 패키지 설치 +RUN apk --no-cache add apache2 + # 앱 디렉토리를 생성하고, 작업 디렉토리로 설정합니다. WORKDIR /app # package.json과 package-lock.json을 복사합니다. COPY package.json package-lock.json ./ -# 의존성을 설치합니다. --legacy-peer-deps 옵션은 필요시 사용할 수 있습니다. +# 의존성을 설치합니다. RUN npm install --legacy-peer-deps # 소스 코드를 모두 복사합니다. @@ -16,8 +19,15 @@ COPY . . # 빌드를 수행합니다. RUN npm run build +# 빌드된 정적 파일을 Apache의 서브 디렉토리로 복사합니다. +RUN cp -r build/* /var/www/html/ + +# Apache를 시작할 때 사용할 스크립트를 설정합니다. +COPY start-apache /usr/local/bin/start-apache +RUN chmod +x /usr/local/bin/start-apache + # 애플리케이션 포트를 노출합니다. -EXPOSE 3000 +EXPOSE 80 -# 앱을 시작하는 명령어입니다. -CMD ["npm", "start"] +# Apache를 시작하는 명령어입니다. +CMD ["start-apache"] \ No newline at end of file