diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee0e39c8..079a0f49 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Python >= 3.11 `nim >=2.0.0` (https://nim-lang.org/install.html) (Note that Debian distros have only packaged `1.6.x` as of Jan 2024) -## FrameOS Controller +## FrameOS Backend ```bash @@ -44,6 +44,7 @@ flask db migrate -m "something changed" # apply the migrations flask db upgrade ``` + ## Installing pre-commit ```bash @@ -62,7 +63,7 @@ cd backend bin/tests ``` -## FrameOS on-device software +## FrameOS on-frame software Running it natively on a Mac will fail with @@ -75,7 +76,7 @@ So we use Docker: ```bash cd frameos -docker build -t frameos . && docker run -t -i frameos python3 test.py +docker build -t frameos-frame . && docker run -t -i frameos python3 test.py ``` # TODO diff --git a/Dockerfile b/Dockerfile index 99f87cf4..8279a8db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,4 +82,4 @@ RUN rm -rf /app/frontend && mv /tmp/frontend /app/ EXPOSE 8989 # Start huey in the background and then run the Flask application -CMD ["bash", "-c", "(redis-server --daemonize yes) && (cd backend && source .venv/bin/activate && flask db upgrade) && (cd backend && source .venv/bin/activate && huey_consumer.py app.huey.huey --worker-type=greenlet --workers=10 --flush-locks) & (cd backend && source .venv/bin/activate && python3 run.py)"] +CMD ["./docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 63f4c625..1164c5f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: ports: - "8989:8989" volumes: - - frameos-data:/app/data + - frameos-db:/app/db volumes: - frameos-data: + frameos-db: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..ba15c4a1 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e # exit as soon as a command fails + +echo "🥕 Starting Redis" +redis-server --daemonize yes + +cd backend +source .venv/bin/activate + +echo "🏃‍♂️ Running migrations" +flask db upgrade + +echo "🍿 Launching Huey" +huey_consumer.py app.huey.huey --worker-type=greenlet --workers=10 --flush-locks & + +echo "🔦 Launching Flask" +python3 run.py