diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e600336 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +build +.git +.github diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..0e7d4ce --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,22 @@ +name: Build and Push React Docker Image + +on: + push: + branches: [main, dev, feat/dockerconnect] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + run: | + docker build -t ${{ secrets.DOCKER_USERNAME }}/react:latest . + docker push ${{ secrets.DOCKER_USERNAME }}/react:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bc39de7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# 빌드 단계 +FROM node:22-alpine AS build +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# 배포 단계 +FROM nginx:alpine +COPY --from=build /app/build /usr/share/nginx/html +COPY default.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..c8e38a6 --- /dev/null +++ b/default.conf @@ -0,0 +1,9 @@ +server { + listen 80; + server_name www.humanicare.store humanicare.store; + root /usr/share/nginx/html; + index index.html; + location / { + try_files $uri $uri/ =404; + } +}