mirror of
https://github.com/Balshgit/public.git
synced 2025-12-17 06:00:40 +03:00
github stars project celery-rabbit
This commit is contained in:
46
new-github-repos/docker/django/Dockerfile
Normal file
46
new-github-repos/docker/django/Dockerfile
Normal 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
|
||||
24
new-github-repos/docker/django/entrypoint.sh
Normal file
24
new-github-repos/docker/django/entrypoint.sh
Normal 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
|
||||
41
new-github-repos/docker/django/gunicorn.sh
Normal file
41
new-github-repos/docker/django/gunicorn.sh
Normal 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'
|
||||
Reference in New Issue
Block a user