Skip to content

Commit

Permalink
added ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheenhyderk committed Mar 11, 2023
1 parent 5217613 commit 8a9dc88
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

.DS_Store
._*
# Django #
*.log
*.pot
*.pyc
__pycache__/
*/__pycache__/
*/*/__pycache__/

migrations/*.py
*/migrations/*.py
*/*/migrations/*.py

!migrations/__init__.py
!*/migrations/__init__.py
!*/*/migrations/__init__.py

media/
logs/

.README.md
.git
.gitignore
.env
.venv
env/
venv/
.vscode
.idea
30 changes: 30 additions & 0 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Dev Django CI

on:
push:
branches: [ "dev-server" ]
pull_request:
branches: [ "dev-server" ]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3


- name: Configure SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}

- name: Deploy
env:
REMOTE_IP: ${{ secrets.DEV_REMOTE_IP }}
PROJECT_PATH: ${{ secrets.PROJECT_PATH }}
run: |
ssh -o StrictHostKeyChecking=no ubuntu@$REMOTE_IP "cd $PROJECT_PATH && docker-compose up --build -d"
30 changes: 30 additions & 0 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Prod Django CI

on:
push:
branches: [ "production" ]
pull_request:
branches: [ "production" ]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3


- name: Configure SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PROD_SSH_PRIVATE_KEY }}

- name: Deploy
env:
REMOTE_IP: ${{ secrets.PROD_REMOTE_IP }}
PROJECT_PATH: ${{ secrets.PROJECT_PATH }}
run: |
ssh -o StrictHostKeyChecking=no ubuntu@$REMOTE_IP "cd $PROJECT_PATH && docker-compose up --build -d"
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.10-slim-buster
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN pip install gunicorn
RUN mkdir /var/log/mulearnbackend
RUN apt-get update -y && apt-get install -y default-libmysqlclient-dev python-dev && apt install build-essential -y
COPY ./requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
ENTRYPOINT sh entrypoint.sh
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'
services:
yipdashboard:
build:
context: .
dockerfile: Dockerfile
container_name: mulearnbackend
image: mulearnbackend
restart: always
ports:
- "8002:8000"
volumes:
- /var/log/mulearnbackend:/var/log/mulearnbackend
env_file:
- .env
2 changes: 2 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
gunicorn --bind 0.0.0.0:8000 mulearnbackend.wsgi
Empty file added models.py
Empty file.

0 comments on commit 8a9dc88

Please sign in to comment.