bramw_baserow/plugin-boilerplate/{{ cookiecutter.project_slu.../docker-compose.multi-servic...

197 lines
6.9 KiB
YAML

version: "3.4"
# MAKE SURE YOU HAVE SET THE REQUIRED VARIABLES IN the .env FILE.configs:
# This compose file starts up a dev version of the plugin with hot code reloading.
# It is accessible at http://localhost:3000 .
services:
# A caddy http server just used for serving media in dev.
caddy:
image: caddy:2
env_file:
- .env
ports:
- "${HOST_PUBLISH_IP:-127.0.0.1}:4000:80"
volumes:
# Override with the dev caddy file which switches Caddy to only be the media file
# server in the dev env. Devs will instead directly connect to the backend and
# web frontend services.
- $PWD/Caddyfile.dev:/etc/caddy/Caddyfile
- media:/baserow/media
- caddy_config:/config
- caddy_data:/data
backend:
image: {{ cookiecutter.project_slug }}_backend_dev
build:
dockerfile: ./backend-dev.Dockerfile
context: .
args:
# We allow configuring the PLUGIN_BUILD_UID/PLUGIN_BUILD_GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
PLUGIN_BUILD_UID: $PLUGIN_BUILD_UID
PLUGIN_BUILD_GID: $PLUGIN_BUILD_GID
environment:
# Dev override variables
- PUBLIC_BACKEND_URL=http://localhost:8000
- PUBLIC_WEB_FRONTEND_URL=http://localhost:3000
- MEDIA_URL=http://localhost:4000/
- BASEROW_PUBLIC_URL=
- BASEROW_BACKEND_DEBUGGER_ENABLED=${BASEROW_BACKEND_DEBUGGER_ENABLED:-True}
- BASEROW_BACKEND_DEBUGGER_PORT=${BASEROW_BACKEND_DEBUGGER_PORT:-5678}
ports:
- "${HOST_PUBLISH_IP:-127.0.0.1}:8000:8000"
- "${HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}"
env_file:
- .env
depends_on:
- db
- redis
volumes:
- media:/baserow/media
- ./plugins/{{ cookiecutter.project_module }}/backend:/baserow/plugins/{{ cookiecutter.project_module }}/backend
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
web-frontend:
image: {{ cookiecutter.project_slug }}_web-frontend_dev
build:
dockerfile: ./web-frontend-dev.Dockerfile
context: .
args:
# We allow configuring the PLUGIN_BUILD_UID/PLUGIN_BUILD_GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
PLUGIN_BUILD_UID: $PLUGIN_BUILD_UID
PLUGIN_BUILD_GID: $PLUGIN_BUILD_GID
environment:
- PUBLIC_BACKEND_URL=http://localhost:8000
- PUBLIC_WEB_FRONTEND_URL=http://localhost:3000
- MEDIA_URL=http://localhost:4000/
- BASEROW_PUBLIC_URL=
ports:
- "${HOST_PUBLISH_IP:-127.0.0.1}:3000:3000"
env_file:
- .env
depends_on:
- backend
volumes:
# Override the for node_modules so we use the node_modules built
# directly into the image instead of whatever is on your local filesystem.
- /baserow/plugins/{{ cookiecutter.project_module }}/web-frontend/node_modules
- ./plugins/{{ cookiecutter.project_module }}/web-frontend:/baserow/plugins/{{ cookiecutter.project_module }}/web-frontend
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
celery:
image: {{ cookiecutter.project_slug }}_backend_dev
env_file:
.env
command: celery-worker
# The backend image's baked in healthcheck defaults to the django healthcheck
# override it to the celery one here.
healthcheck:
test: [ "CMD-SHELL", "/baserow/backend/docker/docker-entrypoint.sh celery-worker-healthcheck" ]
environment:
# Dev override variables
- PUBLIC_BACKEND_URL=http://localhost:8000
- PUBLIC_WEB_FRONTEND_URL=http://localhost:3000
- MEDIA_URL=http://localhost:4000/
- BASEROW_PUBLIC_URL=
depends_on:
- backend
volumes:
- media:/baserow/media
- ./plugins/{{ cookiecutter.project_module }}/backend:/baserow/plugins/{{ cookiecutter.project_module }}/backend
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
celery-export-worker:
image: {{ cookiecutter.project_slug }}_backend_dev
command: celery-exportworker
# The backend image's baked in healthcheck defaults to the django healthcheck
# override it to the celery one here.
healthcheck:
test: [ "CMD-SHELL", "/baserow/backend/docker/docker-entrypoint.sh celery-exportworker-healthcheck" ]
environment:
# Dev override variables
- PUBLIC_BACKEND_URL=http://localhost:8000
- PUBLIC_WEB_FRONTEND_URL=http://localhost:3000
- MEDIA_URL=http://localhost:4000/
- BASEROW_PUBLIC_URL=
depends_on:
- backend
env_file:
.env
volumes:
- media:/baserow/media
- ./plugins/{{ cookiecutter.project_module }}/backend:/baserow/plugins/{{ cookiecutter.project_module }}/backend
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
celery-beat-worker:
image: {{ cookiecutter.project_slug }}_backend_dev
command: celery-beat
# See https://github.com/sibson/redbeat/issues/129#issuecomment-1057478237
stop_signal: SIGQUIT
environment:
# Dev override variables
- PUBLIC_BACKEND_URL=http://localhost:8000
- PUBLIC_WEB_FRONTEND_URL=http://localhost:3000
- MEDIA_URL=http://localhost:4000/
- BASEROW_PUBLIC_URL=
env_file:
- .env
depends_on:
- backend
volumes:
- media:/baserow/media
- ./plugins/{{ cookiecutter.project_module }}/backend:/baserow/plugins/{{ cookiecutter.project_module }}/backend
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
db:
# Please ensure the postgres-client's major version in the backend image is kept in
# sync with this major version so pg_dump remains compatible.
image: postgres:11
env_file:
- .env
environment:
- POSTGRES_USER=${DATABASE_USER:-baserow}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD:?}
- POSTGRES_DB=${DATABASE_NAME:-baserow}
healthcheck:
test: [ "CMD-SHELL", "su postgres -c \"pg_isready -U ${DATABASE_USER:-baserow}\"" ]
interval: 10s
timeout: 5s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data
redis:
image: redis:6
command: redis-server --requirepass ${REDIS_PASSWORD:?}
env_file:
- .env
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
# By default, the media volume will be owned by root on startup. Ensure it is owned by
# the same user that django is running as, so it can write user files.
volume-permissions-fixer:
image: bash:4.4
command: chown ${PLUGIN_BUILD_UID:-1000}:${PLUGIN_BUILD_GID:-1000} -R /baserow/media
volumes:
- media:/baserow/media
volumes:
pgdata:
media:
caddy_data:
caddy_config: