Skip to content
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
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
env/
venv/
.venv/
.git/
.gitignore
*.log
*.sqlite3
*.py[cod]
*.env
.DS_Store
.idea/
.vscode/
30 changes: 30 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Docker Build and Push

on:
push:
branches: ["master"]
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest

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

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: rubonrwra12/taskmanagersystem:latest
Comment on lines +10 to +30

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 12 months ago

To fix the issue, we will add a permissions block at the root of the workflow file. This block will specify the minimal permissions required for the workflow to function. Based on the workflow's steps, it primarily interacts with the repository contents (e.g., checking out the repository) and Docker Hub. Therefore, the contents: read permission is sufficient. No write permissions are required for this workflow.


Suggested changeset 1
.github/workflows/docker-build.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build.yml
@@ -7,2 +7,5 @@
 
+permissions:
+  contents: read
+
 jobs:
EOF
@@ -7,2 +7,5 @@

permissions:
contents: read

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ db.sqlite3

# Environments
.env
.env.docker
.venv/
venv/

Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use the official Python image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=TaskManagerSystem.settings

# Set working directory
WORKDIR /app

# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .

# Expose Django port
EXPOSE 8000

# Run the application with Gunicorn
CMD ["gunicorn", "TaskManagerSystem.wsgi:application", "--bind", "0.0.0.0:8000"]
2 changes: 1 addition & 1 deletion TaskManagerSystem/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
DEBUG = config("DEBUG", default=True, cast=bool)
ALLOWED_HOSTS = config(
"ALLOWED_HOSTS",
default="localhost,127.0.0.1",
default="localhost,127.0.0.1,0.0.0.0",
cast=lambda v: [s.strip() for s in v.split(",")],
)

Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.9'

services:
web:
build: .
container_name: taskmanagersystem
command: gunicorn TaskManagerSystem.wsgi:application --bind 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- .:/app
env_file:
- .env.docker
depends_on:
- db

db:
image: postgres:17
container_name: postgres-db
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "5432:5432"

volumes:
postgres_data:
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ djangorestframework==3.15.2
djangorestframework_simplejwt==5.4.0
drf-nested-routers==0.94.1
drf-yasg==1.21.10
gunicorn==23.0.0
idna==3.10
inflection==0.5.1
packaging==24.2
pip-tools==7.4.1
psycopg2==2.9.10
psycopg2-binary==2.9.10
PyJWT==2.10.1
pyproject_hooks==1.2.0
python-decouple==3.8
Expand Down