gealogiuya
Some checks failed
Deploy Django Application to Server / deploy (push) Failing after 19s
Telegram Notifications / Telegram Gate (push) Failing after 5s

This commit is contained in:
2026-02-27 14:56:23 +05:00
commit 0229a0595c
118 changed files with 33948 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
FROM python:3.10-slim-buster
# Set environment variables to ensure UTF-8 encoding
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8
# Install Flower for Celery monitoring
#RUN pip install flower
# Copy and set permissions for celery worker start script
#COPY ./deployments/compose/django/celery/worker/start /start-celeryworker
#RUN sed -i 's/\r$//g' /start-celeryworker && \
# chmod +x /start-celeryworker
# Copy and set permissions for celery beat start script
#COPY ./deployments/compose/django/celery/beat/start /start-celerybeat
#RUN sed -i 's/\r$//g' /start-celerybeat && \
# chmod +x /start-celerybeat
# Copy and set permissions for flower start script
#COPY ./deployments/compose/django/celery/flower/start /start-flower
#RUN sed -i 's/\r$//g' /start-flower && \
# chmod +x /start-flower
# Update and install necessary packages
RUN apt update && apt upgrade -y && apt install git -y && apt install -y gettext
WORKDIR /app
COPY . /app
# Update pip and install requirements
RUN --mount=type=cache,id=custom-pip,target=/root/.cache/pip \
pip install --upgrade pip && \
pip install -r /app/requirements.txt && \
pip install gunicorn && \
pip install uvicorn
# Copy and set permissions for entrypoint script
COPY ./deployments/compose/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint && \
chmod +x /entrypoint
# Copy and set permissions for start script
COPY ./deployments/compose/django/start /start
RUN sed -i 's/\r$//g' /start && \
chmod +x /start
ENTRYPOINT ["/entrypoint"]

View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -o errexit
set -o nounset
# wait for RabbitMQ server to start
sleep 10
rm -f './celerybeat.pid'
celery -A core beat -l INFO

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -o errexit
set -o nounset
# wait for RabbitMQ server to start
sleep 10
celery -A core --broker="${CELERY_BROKER}" flower

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -o errexit
set -o nounset
# wait for RabbitMQ server to start
sleep 10
celery -A core worker -l INFO

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# if any of the commands in your code fails for any reason, the entire script fails
set -o errexit
# fail exit if one of your pipe command fails
set -o pipefail
# exits if any of your variables is not set
set -o nounset
postgres_ready() {
python << END
import sys
import psycopg2
try:
psycopg2.connect(
dbname="${POSTGRES_DB}",
user="${POSTGRES_USER}",
password="${POSTGRES_PASSWORD}",
host="${POSTGRES_HOST}",
port="${POSTGRES_PORT}",
)
except psycopg2.OperationalError:
sys.exit(-1)
sys.exit(0)
END
}
until postgres_ready; do
>&2 echo 'Waiting for PostgreSQL to become available...'
sleep 1
done
>&2 echo 'PostgreSQL is available'
exec "$@"

View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# Apply Django migrations
#python manage.py makemigrations
python manage.py migrate
python manage.py createadmin
# Collect static files
python manage.py collectstatic --noinput
# Run Gunicorn server with increased timeout
#exec gunicorn core.wsgi:application --bind 0.0.0.0:8000 --timeout 120
# Run Uvicorn server using ASGI
exec uvicorn core.asgi:application --host 0.0.0.0 --port 8000 --reload