From d0a19ba8dcc13d7dbd93f1c3bfe8d1f4ef448fd2 Mon Sep 17 00:00:00 2001 From: sm4640 Date: Sat, 12 Apr 2025 14:38:24 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9E=95=20Dependency:=20[#24]=20gunicorn?= =?UTF-8?q?=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | Bin 912 -> 982 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index d45ea3262e2926b0bff6929bdb8c7ca626508b6b..641927a35550a11fb29bea7fe5f8090ce9d8b5d4 100644 GIT binary patch delta 72 zcmbQhevN&D7n5{4Ln%WZLncEqLq042cZsKs9+l Q5+ZK`lsDQO%Vf+505RPS{Qv*} delta 16 Xcmcb{K7oCM7t`cCCaKM Date: Sat, 12 Apr 2025 14:40:09 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=A7=20Settings:=20[#24]=20dockerfi?= =?UTF-8?q?le=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3849e0e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Use an official Python runtime as a parent image +FROM python:3.12-slim-bullseye + +# Set environment variables +ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 + +# Set the working directory +WORKDIR /app + +# Install Python dependencies +COPY requirements.txt /app/ + +# 시스템 패키지 설치 +RUN apt-get update && apt-get install -y \ + build-essential \ + libpq-dev \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +# 첫 번째 시도 +RUN pip install --upgrade pip || \ + # 실패할 경우, python.exe -m pip로 재시도 + python.exe -m pip install --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the Django project +COPY . /app/ \ No newline at end of file From aef9ea93514f51314b29310e88885a308bf32f2c Mon Sep 17 00:00:00 2001 From: sm4640 Date: Sat, 12 Apr 2025 14:40:43 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A7=20Settings:=20[#24]=20dockerig?= =?UTF-8?q?nore=20=ED=8C=8C=EC=9D=BC=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..df27c68 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.gitignore +.dockerignore +Dockerfile +venv/ +local_settings.py +__pycache__/ +media +.env +db.sqlite3 +migrations +README.md \ No newline at end of file From 556b98f9658a334d833d743a1b055a5d2549de43 Mon Sep 17 00:00:00 2001 From: sm4640 Date: Sat, 12 Apr 2025 14:43:22 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=A7=20Settings:=20[#24]=20CI=20/?= =?UTF-8?q?=20CD=20=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/workflow.yml | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..a2ef272 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,52 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - dev + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # 코드 체크아웃 + - name: Checkout code + uses: actions/checkout@v2 + + # 더 나은 도커 빌드 환경 세팅 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + # DockerHub 로그인 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO }}:latest + + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + # AWS 배포 + - name: SSH to EC2 and deploy + uses: appleboy/ssh-action@v0.1.3 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + docker compose stop ${{ secrets.DOCKER_HUB_REPO }} + docker compose rm ${{ secrets.DOCKER_HUB_REPO }} + docker rmi ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO }}:latest + docker compose up -d