Hi,
I was wondering how to deploy docker to production mode? i have docker-compose where i have services which depends on each other. Here is docker-compose.yml file
version: '3'
services:
rq_default_worker:
build: .
env_file:
- web.env
command: ["./scripts/wait-for-it.sh", "web:8000", "--", "bash", "./scripts/run_rq_default_worker.sh"]
volumes:
- .:/code
links:
- db
- redis
depends_on:
- web
rq_high_worker:
build: .
env_file:
- web.env
command: ["./scripts/wait-for-it.sh", "web:8000", "--", "bash", "./scripts/run_rq_high_worker.sh"]
volumes:
- .:/code
links:
- db
- redis
depends_on:
- web
rq_low_worker:
build: .
env_file:
- web.env
command: ["./scripts/wait-for-it.sh", "web:8000", "--", "bash", "./scripts/run_rq_low_worker.sh"]
volumes:
- .:/code
links:
- db
- redis
depends_on:
- web
rq_default_scheduler:
build: .
env_file:
- web.env
command: ["./scripts/wait-for-it.sh", "web:8000", "--", "bash", "./scripts/run_default_rq_scheduler.sh"]
volumes:
- .:/code
links:
- db
- redis
depends_on:
- web
redis:
image: "redis:latest"
ports:
- "6379:6379"
volumes:
- ./docker/redis/data:/data
db:
image: postgres
restart: always
env_file:
- db.env
volumes:
- ./docker/postgres/data:/var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
nginx:
restart: always
image: nginx:alpine
volumes:
- ./docker/nginx/conf.d:/etc/nginx/conf.d
- ./logs:/code/logs/
- ./static:/code/static/
- ./media:/code/media/
ports:
- "80:80"
- "443:443"
links:
- web
web:
image: registry.gitlab.com/user/repo:latest
container_name: "xing-auto-services-django"
env_file:
- web.env
build: .
command: ["./scripts/wait-for-it.sh", "db:5432", "--", "bash", "./scripts/run_server.sh"]
volumes:
- .:/code
- ./static:/code/static/
- ./media:/code/media/
ports:
- "8000:8000"
links:
- db
- redis
restart: always
depends_on:
- db
- redis
if i use docker-compose up, my container would according to what i want such as it waits for services to up and running. But once i tried to run it using docker
however it only run python3
not the command i described in web
from services
. I google a lot but some people said we can deploy it using swarm
or just use up
and some said entry-point
in DockerFile.
Here is my DockerFile:
FROM python:3
ENV PYTHONUNBUFFERED 1
ARG token
WORKDIR /code
COPY requirements.txt /code/
# BE SURE TO GIVE GITLAB ACCESS TOKEN!
RUN git config --global url."https://oauth2:${token}@gitlab.com/".insteadOf "https://gitlab.com/" && pip install --no-cache-dir -r requirements.txt --force-reinstall
COPY . /code/
But it will work according to docker-compose up
? and if there is anyone who have experience with nginx
with docker. Is it possible to run multiple containers with same port? i guess no. Maybe i have to use nginx proxy. But again i may need to modify all of my docker-compose
if in cause i have multiple projects in one server.
Thanks!