Refactor much needed docker setup
- Build static files inside seperate container - Remove unnecessary env variables
This commit is contained in:
parent
d61b3a9498
commit
7fc899937d
5 changed files with 59 additions and 37 deletions
|
|
@ -1,52 +1,56 @@
|
|||
version: '3'
|
||||
volumes:
|
||||
postgres-data:
|
||||
static-files:
|
||||
node-modules:
|
||||
|
||||
services:
|
||||
db:
|
||||
# See https://hub.docker.com/_/postgres
|
||||
image: postgres
|
||||
container_name: postgres
|
||||
environment:
|
||||
- POSTGRES_DB=$POSTGRES_NAME
|
||||
- POSTGRES_USER=$POSTGRES_USER
|
||||
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||
POSTGRES_DB: "newsreader"
|
||||
POSTGRES_USER: "newsreader"
|
||||
POSTGRES_PASSWORD: "newsreader"
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
rabbitmq:
|
||||
image: rabbitmq:3.7
|
||||
container_name: rabbitmq
|
||||
celery:
|
||||
build: .
|
||||
container_name: celery
|
||||
command: poetry run celery -A newsreader worker -l INFO --beat --scheduler django --workdir=/app/src/
|
||||
environment:
|
||||
- POSTGRES_HOST=$POSTGRES_HOST
|
||||
- POSTGRES_NAME=$POSTGRES_NAME
|
||||
- POSTGRES_USER=$POSTGRES_USER
|
||||
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||
- DJANGO_SETTINGS_MODULE=newsreader.conf.docker
|
||||
volumes:
|
||||
- .:/app
|
||||
depends_on:
|
||||
- rabbitmq
|
||||
memcached:
|
||||
image: memcached:1.5.22
|
||||
container_name: memcached
|
||||
ports:
|
||||
- "11211:11211"
|
||||
entrypoint:
|
||||
- memcached
|
||||
- -m 64
|
||||
web:
|
||||
build: .
|
||||
container_name: web
|
||||
celery:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./docker/django
|
||||
command: celery worker --app newsreader --loglevel INFO --beat --scheduler django --workdir /app/src/
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=newsreader.conf.docker
|
||||
depends_on:
|
||||
- rabbitmq
|
||||
django:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./docker/django
|
||||
command: src/entrypoint.sh
|
||||
environment:
|
||||
- POSTGRES_HOST=$POSTGRES_HOST
|
||||
- POSTGRES_NAME=$POSTGRES_NAME
|
||||
- POSTGRES_USER=$POSTGRES_USER
|
||||
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||
- DJANGO_SETTINGS_MODULE=newsreader.conf.docker
|
||||
volumes:
|
||||
- .:/app
|
||||
ports:
|
||||
- '8000:8000'
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- .:/app
|
||||
- static-files:/app/src/newsreader/static
|
||||
webpack:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./docker/webpack
|
||||
command: npm run build:watch
|
||||
volumes:
|
||||
- .:/app
|
||||
- static-files:/app/src/newsreader/static
|
||||
- node-modules:/app/node_modules
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ RUN pip install poetry
|
|||
WORKDIR /app
|
||||
COPY poetry.lock pyproject.toml /app/
|
||||
|
||||
RUN poetry config virtualenvs.create false
|
||||
RUN poetry install --no-interaction
|
||||
RUN poetry config virtualenvs.create false && poetry install --no-interaction
|
||||
|
||||
COPY . /app/
|
||||
9
docker/webpack
Normal file
9
docker/webpack
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
FROM node:12
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json /app/
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . /app/
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# This file should only be used in conjuction with docker-compose
|
||||
|
||||
poetry run /app/src/manage.py migrate
|
||||
poetry run /app/src/manage.py runserver 0.0.0.0:8000
|
||||
python /app/src/manage.py migrate
|
||||
python /app/src/manage.py runserver 0.0.0.0:8000
|
||||
|
|
|
|||
|
|
@ -3,9 +3,15 @@ from .dev import * # isort:skip
|
|||
|
||||
SECRET_KEY = "=q(ztyo)b6noom#a164g&s9vcj1aawa^g#ing_ir99=_zl4g&$"
|
||||
|
||||
# Celery
|
||||
# https://docs.celeryproject.org/en/latest/userguide/configuration.html
|
||||
BROKER_URL = "amqp://guest:guest@rabbitmq:5672//"
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": "newsreader",
|
||||
"USER": "newsreader",
|
||||
"PASSWORD": "newsreader",
|
||||
"HOST": "db",
|
||||
}
|
||||
}
|
||||
|
||||
CACHES = {
|
||||
"default": {
|
||||
|
|
@ -17,3 +23,7 @@ CACHES = {
|
|||
"LOCATION": "memcached:11211",
|
||||
},
|
||||
}
|
||||
|
||||
# Celery
|
||||
# https://docs.celeryproject.org/en/latest/userguide/configuration.html
|
||||
CELERY_BROKER_URL = "amqp://guest:guest@rabbitmq:5672//"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue