From c799bce49e6232b5e6c83938be8e8ae9418c34e4 Mon Sep 17 00:00:00 2001 From: seokjin1023 Date: Sat, 3 May 2025 12:21:14 +0900 Subject: [PATCH 1/2] feat: dockerconnect --- .dockerignore | 4 ++++ .github/workflows/deploy.yml | 22 ++++++++++++++++++++++ Dockerfile | 13 +++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile 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..29bc9d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# 빌드 단계 +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 +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] From 5e77cbb182cadfe5a25d9087a006a1ec3f988881 Mon Sep 17 00:00:00 2001 From: seokjin1023 Date: Sat, 3 May 2025 17:44:57 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20dockerfile=20conf=20domain=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 + default.conf | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 default.conf diff --git a/Dockerfile b/Dockerfile index 29bc9d0..bc39de7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,5 +9,6 @@ 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; + } +}