Skip to content

Commit

Permalink
the simplest docker compose works!
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Sep 2, 2023
1 parent 2ccd782 commit ed6a69d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
8 changes: 4 additions & 4 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM papermerge/tivoli:0.2.0 as token_validator
FROM papermerge/auth-server:0.4.1 as auth_server
FROM papermerge/auth-server:0.4.3 as auth_server
FROM python:3.10 as papermerge_core

ENV CORE_APP=/core_app
ENV PAPERMERGE__DATABASE__URL=sqlite:////db/db.sqlite3
ENV DJANGO_SETTINGS_MODULE=config.settings
ENV DJANGO_SUPERUSER_USERNAME=admin
ENV DJANGO_SUPERUSER_EMAIL=admin@example.com
ENV PAPERMERGE__AUTH__USERNAME=admin
ENV PAPERMERGE__AUTH__EMAIL=admin@example.com

ENV VIRTUAL_ENV=${CORE_APP}/.venv

Expand Down Expand Up @@ -36,7 +36,7 @@ RUN poetry install --no-root -vvv
COPY docker/dev/run.bash /run.bash
COPY docker/dev/supervisord.conf /etc/
COPY docker/dev/nginx.conf /etc/nginx/nginx.conf
COPY docker/dev/logging.yaml ${CORE_APP}/logging.yaml
COPY docker/dev/logging.yml ${CORE_APP}/logging.yml
### COPY ./papermerge ${CORE_APP}/papermerge/
COPY ./docker/dev/config ${CORE_APP}/config
COPY ./docker/dev/manage.py ${CORE_APP}/manage.py
Expand Down
3 changes: 3 additions & 0 deletions docker/dev/logging.yaml → docker/dev/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ handlers:
formatter: verbose

loggers:
auth_server:
level: DEBUG
handlers: [console]
papermerge.search.tasks:
level: DEBUG
handlers: [console]
Expand Down
18 changes: 4 additions & 14 deletions docker/dev/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,12 @@ exec_server() {

exec_migrate() {
# run migrations
cd /core_app && poetry run ./manage.py migrate --no-input
VIRTUAL_ENV=/core_app/.venv && cd /core_app && poetry run ./manage.py migrate --no-input
}


exec_createsuperuser() {
# user envrironment variables:
# (1) DJANGO_SUPERUSER_USERNAME
# (2) DJANGO_SUPERUSER_EMAIL
# (3) DJANGO_SUPERUSER_PASSWORD
# to create superuser if (1) and (2) are set
if [ -n "${DJANGO_SUPERUSER_USERNAME}" ] && [ -n "${DJANGO_SUPERUSER_EMAIL}" ]; then
echo "Creating superuser username=${DJANGO_SUPERUSER_USERNAME}"
cd /core_app && poetry run ./manage.py createsuperuser --noinput \
--username ${DJANGO_SUPERUSER_USERNAME} \
--email ${DJANGO_SUPERUSER_EMAIL} || true
fi
VIRTUAL_ENV=/auth_server_app/.venv && cd /auth_server_app/ && poetry install && poetry run create_user || true
}

exec_worker() {
Expand All @@ -40,7 +30,7 @@ exec_worker() {
}

exec_index_schema_apply() {
exec /core_app/.venv/bin/python manage.py index_schema apply
VIRTUAL_ENV=/core_app/.venv && cd /core_app && poetry run ./manage.py index_schema apply
}

exec_init() {
Expand All @@ -60,7 +50,7 @@ case $CMD in
;;
server)
exec_init
poetry run ./manage.py index_schema apply
VIRTUAL_ENV=/core_app/.venv && cd /core_app && poetry run ./manage.py index_schema apply
roco > /usr/share/nginx/html/auth_server/papermerge-runtime-config.js
exec /usr/bin/supervisord
;;
Expand Down
4 changes: 2 additions & 2 deletions docker/dev/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stderr_logfile_maxbytes=0


[program:core]
command=poetry run uvicorn config.asgi:fastapp --host 0.0.0.0 --app-dir /core_app/ --reload --reload-dir /core_app/papermerge --log-config /core_app/logging.yaml --log-level debug --port 8000
command=poetry run uvicorn config.asgi:fastapp --host 0.0.0.0 --app-dir /core_app/ --reload --reload-dir /core_app/papermerge --log-config /core_app/logging.yml --log-level debug --port 8000
priority=2
directory=/core_app
environment=PATH="/core_app/.venv/bin:%(ENV_PATH)s"
Expand All @@ -32,7 +32,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:auth_server]
command=poetry run uvicorn auth_server.main:app --host 0.0.0.0 --port 4010
command=poetry run uvicorn auth_server.main:app --host 0.0.0.0 --port 4010 --log-config /core_app/logging.yml --log-level debug
priority=2
directory=/auth_server_app
environment=VIRTUAL_ENV="/auth_server_app/.venv/"
Expand Down
5 changes: 3 additions & 2 deletions papermerge/core/routers/ws.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logging

from fastapi import APIRouter, Depends, WebSocket, WebSocketDisconnect
from fastapi import APIRouter, Depends, WebSocket

from papermerge.core.models import User
from papermerge.core.notif import notification

from .auth import get_ws_current_user

Expand Down Expand Up @@ -45,6 +44,7 @@ async def websocket_endpoint(
to the websocket clients (to the current/session user).
"""
await manager.connect(websocket)
"""
try:
while True:
async for message in notification:
Expand All @@ -58,3 +58,4 @@ async def websocket_endpoint(
except WebSocketDisconnect:
logger.info("Websocket disconnected")
manager.disconnect(websocket)
"""
3 changes: 2 additions & 1 deletion simplest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- ./ui:/core_ui/
environment:
PAPERMERGE__SECURITY__SECRET_KEY: 1234 # top secret
DJANGO_SUPERUSER_PASSWORD: 1234
PAPERMERGE__AUTH__USERNAME: admin
PAPERMERGE__AUTH__PASSWORD: 1234
ports:
- "11000:80"

0 comments on commit ed6a69d

Please sign in to comment.