Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI/CD

on:
pull_request:
branches:
- develop

jobs:
test:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Write .env file
run: echo "${{ secrets.ENV_FILE }}" > .env

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run Tests
env:
ENV_FILE: ${{ secrets.ENV_FILE }}
run: |
python manage.py test --keepdb

deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

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

- name: Write .env file
run: echo "${{ secrets.ENV_FILE }}" > .env

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.USERNAME }}
password: ${{ secrets.TOKEN }}

- name: Build and Push Docker Image
run: |
docker build -t ghcr.io/kianyari/web:latest .
docker push ghcr.io/kianyari/web:latest

- name: Deploy to Server
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
docker pull ghcr.io/kianyari/web:latest
docker stop web || true
docker rm web || true
docker run -d --name web -p 8000:8000 ghcr.io/kianyari/web:latest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Makefile
venv/
.env
**/__pycache__/
Dockerfile
# Dockerfile
docker-compose.yml
.Dockerignore
.env.docker
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use the official Python image from the Docker Hub
FROM python:3.12-alpine

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Set the working directory
WORKDIR /app

# Install system dependencies
RUN apk add --no-cache gcc musl-dev mariadb-connector-c-dev mariadb-dev pkgconfig

# Install Python dependencies
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --upgrade 'sentry-sdk[django]'

# Copy the project files
COPY . /app/

# Expose the port your app runs on
EXPOSE 8000

# Run the application
CMD ["daphne", "FD.asgi:application", "--bind", "0.0.0.0", "--port", "8000"]