Skip to content

Commit 8a9dc88

Browse files
committed
added ci/cd
1 parent 5217613 commit 8a9dc88

7 files changed

+120
-0
lines changed

.dockerignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
.DS_Store
3+
._*
4+
# Django #
5+
*.log
6+
*.pot
7+
*.pyc
8+
__pycache__/
9+
*/__pycache__/
10+
*/*/__pycache__/
11+
12+
migrations/*.py
13+
*/migrations/*.py
14+
*/*/migrations/*.py
15+
16+
!migrations/__init__.py
17+
!*/migrations/__init__.py
18+
!*/*/migrations/__init__.py
19+
20+
media/
21+
logs/
22+
23+
.README.md
24+
.git
25+
.gitignore
26+
.env
27+
.venv
28+
env/
29+
venv/
30+
.vscode
31+
.idea

.github/workflows/dev-deploy.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Dev Django CI
2+
3+
on:
4+
push:
5+
branches: [ "dev-server" ]
6+
pull_request:
7+
branches: [ "dev-server" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
20+
- name: Configure SSH key
21+
uses: webfactory/[email protected]
22+
with:
23+
ssh-private-key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
24+
25+
- name: Deploy
26+
env:
27+
REMOTE_IP: ${{ secrets.DEV_REMOTE_IP }}
28+
PROJECT_PATH: ${{ secrets.PROJECT_PATH }}
29+
run: |
30+
ssh -o StrictHostKeyChecking=no ubuntu@$REMOTE_IP "cd $PROJECT_PATH && docker-compose up --build -d"

.github/workflows/prod-deploy.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Prod Django CI
2+
3+
on:
4+
push:
5+
branches: [ "production" ]
6+
pull_request:
7+
branches: [ "production" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
20+
- name: Configure SSH key
21+
uses: webfactory/[email protected]
22+
with:
23+
ssh-private-key: ${{ secrets.PROD_SSH_PRIVATE_KEY }}
24+
25+
- name: Deploy
26+
env:
27+
REMOTE_IP: ${{ secrets.PROD_REMOTE_IP }}
28+
PROJECT_PATH: ${{ secrets.PROJECT_PATH }}
29+
run: |
30+
ssh -o StrictHostKeyChecking=no ubuntu@$REMOTE_IP "cd $PROJECT_PATH && docker-compose up --build -d"

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.10-slim-buster
2+
WORKDIR /app
3+
ENV PYTHONDONTWRITEBYTECODE=1
4+
ENV PYTHONUNBUFFERED=1
5+
RUN pip install gunicorn
6+
RUN mkdir /var/log/mulearnbackend
7+
RUN apt-get update -y && apt-get install -y default-libmysqlclient-dev python-dev && apt install build-essential -y
8+
COPY ./requirements.txt .
9+
RUN pip install -r requirements.txt
10+
COPY . .
11+
EXPOSE 8000
12+
ENTRYPOINT sh entrypoint.sh

docker-compose.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3'
2+
services:
3+
yipdashboard:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
container_name: mulearnbackend
8+
image: mulearnbackend
9+
restart: always
10+
ports:
11+
- "8002:8000"
12+
volumes:
13+
- /var/log/mulearnbackend:/var/log/mulearnbackend
14+
env_file:
15+
- .env

entrypoint.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
gunicorn --bind 0.0.0.0:8000 mulearnbackend.wsgi

models.py

Whitespace-only changes.

0 commit comments

Comments
 (0)