github stars project celery-rabbit

This commit is contained in:
2021-07-06 16:36:19 +03:00
commit 70bff65fc0
85 changed files with 6716 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
FROM python:3.8.9-slim-buster
ENV BUILD_ONLY_PACKAGES='wget' \
# python:
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PYTHONDONTWRITEBYTECODE=1 \
# pip:
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
POETRY_VERSION=1.1.4 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
PATH="$PATH:/root/.poetry/bin"
# System deps:
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
bash \
build-essential \
curl \
gettext \
git \
libpq-dev \
nano \
# Defining build-time-only dependencies:
$BUILD_ONLY_PACKAGES \
&& curl -sSL 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py' | python \
&& poetry --version \
# Removing build-time-only dependencies:
&& apt-get remove -y $BUILD_ONLY_PACKAGES \
# Cleaning cache:
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* \
&& rm -rf $POETRY_CACHE_DIR
WORKDIR /code
# Copy only requirements, to cache them in docker layer
COPY ./poetry.lock ./pyproject.toml /code/
RUN poetry install
COPY . /code

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env sh
set -o errexit
set -o nounset
readonly cmd="$*"
postgres_ready () {
# Check that postgres is up and running on port `5432`:
dockerize -wait 'tcp://db:5432' -timeout 5s
}
# We need this line to make sure that this container is started
# after the one with postgres:
until postgres_ready; do
>&2 echo 'Postgres is unavailable - sleeping'
done
# It is also possible to wait for other services as well: redis, elastic, mongo
>&2 echo 'Postgres is up - continuing...'
# Evaluating passed command (do not touch):
# shellcheck disable=SC2086
exec $cmd

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env sh
set -o errexit
set -o nounset
# We are using `gunicorn` for production, see:
# http://docs.gunicorn.org/en/stable/configure.html
# Check that $DJANGO_ENV is set to "production",
# fail otherwise, since it may break things:
echo "DJANGO_ENV is $DJANGO_ENV"
if [ "$DJANGO_ENV" != 'production' ]; then
echo 'Error: DJANGO_ENV is not set to "production".'
echo 'Application will not start.'
exit 1
fi
export DJANGO_ENV
# Run python specific scripts:
# Running migrations in startup script might not be the best option, see:
# docs/pages/template/production-checklist.rst
python /code/manage.py migrate --noinput
python /code/manage.py collectstatic --noinput
python /code/manage.py compilemessages
# Start gunicorn:
# Docs: http://docs.gunicorn.org/en/stable/settings.html
# Concerning `workers` setting see:
# https://github.com/wemake-services/wemake-django-template/issues/1022
/usr/local/bin/gunicorn server.wsgi \
--workers=4 `# Sync worker settings` \
--max-requests=2000 \
--max-requests-jitter=400 \
--bind='0.0.0.0:8000' `# Run Django on 8000 port` \
--chdir='/code' `# Locations` \
--log-file=- \
--worker-tmp-dir='/dev/shm'