Skip to content

Commit

Permalink
feat: separated ws deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Dec 29, 2023
1 parent f7c3d8d commit 74cfdaf
Show file tree
Hide file tree
Showing 8 changed files with 1,735 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

- name: Install dependencies
run: |
pip install --upgrade pip poetry
pip install --upgrade pip poetry==1.7.1
poetry config virtualenvs.create false --local
poetry install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dmypy.json

# Static files
media/
static/

# Gunicorn access
gunicorn.access
1 change: 0 additions & 1 deletion chats/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

application = ProtocolTypeRouter(
{
"http": django_asgi_app,
"websocket": TokenAuthMiddleware(URLRouter(websocket_urlpatterns)),
}
)
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export GUNICORN_APP=${GUNICORN_APP:-"chats.asgi"}
export GUNICORN_APP=${GUNICORN_APP:-"chats.wsgi"}
export CELERY_APP=${CELERY_APP:-"chats"}
export GUNICORN_CONF=${GUNICORN_CONF:-"${PROJECT_PATH}/docker/gunicorn/gunicorn.conf.py"}
export LOG_LEVEL=${LOG_LEVEL:-"INFO"}
Expand Down
70 changes: 35 additions & 35 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# syntax = docker/dockerfile:1

ARG PYTHON_VERSION="3.9"
ARG POETRY_VERSION="1.1.15"
ARG POETRY_VERSION="1.7.1"

ARG BUILD_DEPS="\
python3-dev \
build-essential \
gettext \
libpq-dev \
cmake \
pkg-config \
autoconf \
libtool \
automake"
python3-dev \
build-essential \
gettext \
libpq-dev \
cmake \
pkg-config \
autoconf \
libtool \
automake"

ARG RUNTIME_DEPS="\
tzdata \
curl \
gosu \
gettext \
postgresql-client \
ffmpeg \
libmagic1"
tzdata \
curl \
gosu \
gettext \
postgresql-client \
ffmpeg \
libmagic1"

FROM python:${PYTHON_VERSION}-slim as base

Expand All @@ -31,28 +31,28 @@ ARG APP_VERSION="0.1"

# set environment variables
ENV APP_VERSION=${APP_VERSION} \
RUNTIME_DEPS=${RUNTIME_DEPS} \
BUILD_DEPS=${BUILD_DEPS} \
APPLICATION_NAME="Chats" \
PROJECT_PATH=/chats \
PROJECT_USER=app_user \
PROJECT_GROUP=app_group \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PATH="/install/bin:${PATH}" \
APP_PORT=${APP_PORT}
RUNTIME_DEPS=${RUNTIME_DEPS} \
BUILD_DEPS=${BUILD_DEPS} \
APPLICATION_NAME="Chats" \
PROJECT_PATH=/chats \
PROJECT_USER=app_user \
PROJECT_GROUP=app_group \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PATH="/install/bin:${PATH}" \
APP_PORT=${APP_PORT}

LABEL app=${VERSION} \
os="debian" \
os.version="10" \
name="${APPLICATION_NAME} ${APP_VERSION}" \
description="${APPLICATION_NAME} image" \
maintainer="${APPLICATION_NAME} Team"
os="debian" \
os.version="10" \
name="${APPLICATION_NAME} ${APP_VERSION}" \
description="${APPLICATION_NAME} image" \
maintainer="${APPLICATION_NAME} Team"

RUN addgroup --gid 1999 "${PROJECT_GROUP}" \
&& useradd --system -m -d ${PROJECT_PATH} -u 1999 -g 1999 "${PROJECT_USER}"
&& useradd --system -m -d ${PROJECT_PATH} -u 1999 -g 1999 "${PROJECT_USER}"

# set work directory
WORKDIR ${PROJECT_PATH}
Expand Down
1 change: 0 additions & 1 deletion gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
workers = os.environ.get("GUNICORN_WORKERS", multiprocessing.cpu_count() * 2 + 1)
proc_name = "chats"
default_proc_name = proc_name
worker_class = "uvicorn.workers.UvicornWorker"
accesslog = "gunicorn.access"
timeout = 120
bind = "0.0.0.0"
Expand Down
Loading

0 comments on commit 74cfdaf

Please sign in to comment.