+ python services and python nginx conf example
+ also example of Dockerfile for python project and needed to place onto your project directory
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
# For UFW allowing ports on the host system: ufw allow to 172.18.0.1 port 9000,9003
|
# For UFW allowing ports on the host system: ufw allow to 172.18.0.1 port 9000,9003
|
||||||
DOCKER_HOST_IP=172.18.0.1
|
DOCKER_HOST_IP=172.18.0.1
|
||||||
PROJECTS_DIR=/home/youruser/PhpstormProjects
|
PROJECTS_DIR=/home/youruser/PhpstormProjects
|
||||||
|
PYTHON_PROJECTS_DIR=/home/dimti/PythonProjects
|
||||||
|
|
||||||
### Common ###############################################
|
### Common ###############################################
|
||||||
CUSTOM_TZ=Europe/Moscow
|
CUSTOM_TZ=Europe/Moscow
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
map $http_host $python_upstream {
|
map $http_host $python_upstream {
|
||||||
someproject.local.wpstudio.ru http://workspace74:8000;
|
someproject.local.wpstudio.ru http://python-someproject:8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
map $http_host $python_root {
|
map $http_host $python_root {
|
||||||
|
@ -4,6 +4,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ${PROJECTS_DIR}:/usr/share/nginx/html
|
- ${PROJECTS_DIR}:/usr/share/nginx/html
|
||||||
|
- ${PYTHON_PROJECTS_DIR}:/usr/share/nginx/python
|
||||||
- ./config/nginx/conf.d:/etc/nginx/conf.d
|
- ./config/nginx/conf.d:/etc/nginx/conf.d
|
||||||
- ./config/nginx/includes.d:/etc/nginx/includes.d
|
- ./config/nginx/includes.d:/etc/nginx/includes.d
|
||||||
- ./config/nginx/ssl.d:/etc/nginx/ssl.d
|
- ./config/nginx/ssl.d:/etc/nginx/ssl.d
|
||||||
|
16
docker-compose.python.yml.example
Executable file
16
docker-compose.python.yml.example
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
services:
|
||||||
|
python-someproject:
|
||||||
|
user: ${WORKSPACE_PUID}:${WORKSPACE_PGID}
|
||||||
|
build:
|
||||||
|
context: ${PYTHON_PROJECTS_DIR}/someproject
|
||||||
|
args:
|
||||||
|
- PUID=${WORKSPACE_PUID}
|
||||||
|
- PGID=${WORKSPACE_PGID}
|
||||||
|
- PYTHON_VERSION=3.9.20
|
||||||
|
volumes:
|
||||||
|
- ${PYTHON_PROJECTS_DIR}/someproject:/app
|
||||||
|
command: bash --init-file /venv/bin/activate -c "
|
||||||
|
python manage.py migrate
|
||||||
|
&& python manage.py collectstatic
|
||||||
|
&& uvicorn 'APP_NAME.asgi:application' --host 0.0.0.0
|
||||||
|
"
|
27
dockerfiles/python/Dockerfile.example
Normal file
27
dockerfiles/python/Dockerfile.example
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
ARG PYTHON_VERSION
|
||||||
|
FROM python:${PYTHON_VERSION}
|
||||||
|
|
||||||
|
ARG PUID=1000
|
||||||
|
ARG PGID=1000
|
||||||
|
|
||||||
|
RUN groupadd -g ${PGID} pydock && \
|
||||||
|
useradd -u ${PUID} -g pydock -m pydock && \
|
||||||
|
usermod -p "*" pydock -s /bin/bash
|
||||||
|
|
||||||
|
RUN mkdir /venv && chown ${PUID}:${PGID} /venv
|
||||||
|
|
||||||
|
USER pydock
|
||||||
|
|
||||||
|
# Создаём виртуальное окружение ВНЕ /app
|
||||||
|
RUN python -m venv /venv
|
||||||
|
ENV PATH="/venv/bin:$PATH"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
VOLUME /pip_cache
|
||||||
|
|
||||||
|
RUN . /venv/bin/activate && pip install --cache-dir=/pip_cache -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 8000
|
2
dockerfiles/python/README.md
Normal file
2
dockerfiles/python/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Как вы уже поняли, это файл должен лежать в корневой директории проекта,
|
||||||
|
так как нужно копировать от туда requirements.txt при сборке образа.
|
Reference in New Issue
Block a user