Answer the question
In order to leave comments, you need to log in
How to make a service in Docker always on?
Hello, there is a need to make project documentation on a separate port using docker for this. At the moment in the yml file like this:
services:
nginx:
restart: always
build:
context: .
dockerfile: docker/local/nginx/Dockerfile
image: kenguru_local_nginx
depends_on:
- django
ports:
- 80:80
- 443:443
django: &django
restart: always
build:
context: .
dockerfile: docker/local/django/Dockerfile
image: kenguru_local_django
depends_on:
- postgres
- mailhog
volumes:
- .:/app
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
expose:
- 8000
command: gunicorn project.wsgi --bind 0.0.0.0:8000 --reload --worker-class=gevent --worker-connections=1000 --workers 3 --timeout 120
docs:
image: kenguru_local_docs
container_name: docs
build:
context: .
dockerfile: ./docker/local/docs/Dockerfile
env_file:
- ./.envs/.local/.django
volumes:
- ./docs:/docs
- ./config:/app/config
- ./project:/app/project
ports:
- "7000:7000"
expose:
- 7000
FROM python:3.7-slim-buster
ENV PYTHONUNBUFFERED 1
RUN apt-get update \
# dependencies for building Python packages
&& apt-get install -y build-essential \
# psycopg2 dependencies
&& apt-get install -y libpq-dev \
# Translations dependencies
&& apt-get install -y gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
RUN pip install sphinx && pip install sphinx-rtd-theme
WORKDIR /docs
CMD make html
Answer the question
In order to leave comments, you need to log in
Here's how you can assemble
FROM python:3.7-slim-buster as docs
ENV PYTHONUNBUFFERED 1
RUN apt-get update \
# dependencies for building Python packages
&& apt-get install -y build-essential \
# psycopg2 dependencies
&& apt-get install -y libpq-dev \
# Translations dependencies
&& apt-get install -y gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
RUN pip install sphinx && pip install sphinx-rtd-theme
WORKDIR /docs
CMD make html
###
FROM nginx:latest as nginx
COPY --from=docs /docs /var/www/html/public
CMD ["nginx", "-g", "daemon off;"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question