Here is a high-level overview of the different components that make Anthias:
These components and their dependencies are mostly installed and handled with Ansible and Docker.
- The NGINX component (
anthias-nginx
) forwards requests to the backend and serves static files. It also acts as a reverse proxy. - The viewer (
anthias-viewer
) is what drives the screen (e.g., shows web page, image or video). - The web app component (
anthias-server
) — which consists of the front-end and back-end code – is what the user interacts with via browser. - The Celery (
anthias-celery
) component is for aynschronouslt queueing and executing tasks outside the HTTP request-response cycle (e.g., doing assets cleanup). - The WebSocket (
anthias-websocket
) component is used for forwarding requests from NGINX to the backend. - Redis (
redis
) is used as a database, cache and message broker. - The database component uses SQLite for storing the assets information.
To simplify development of the server module of Anthias, we've created a Docker container. This is intended to run on your local machine with the Anthias repository mounted as a volume.
Important
- Make sure that you have installed Docker on your machine before proceeding.
- Anthias is using Docker's buildx for the image builds. This is used both for cross compilation as well as for local caching. You might need to run
docker buildx create --use
first.
Assuming you're in the source code repository, simply run:
$ ./bin/start_development_server.sh
# The console output was truncated for brevity.
# ...
[+] Running 6/6
✔ Network anthias_default Created 0.1s
✔ Container anthias-redis-1 Started 0.2s
✔ Container anthias-anthias-server-1 Started 0.2s
✔ Container anthias-anthias-celery-1 Started 0.3s
✔ Container anthias-anthias-websocket-1 Started 0.4s
✔ Container anthias-anthias-nginx-1 Started 0.5s
Note
Running the script will install Python 3.11, pyenv, and Poetry inside a Docker container on your machine. This is to ensure that the development environment is consistent across different machines.
The script currently supports Debian-based systems and macOS.
unning the command above will start the development server and you should be able to
access the web interface at http://localhost:8000
.
To stop the development server, run the following:
docker compose -f docker-compose.dev.yml down
Note
Make sure that you have Docker installed on the device before proceeding.
$ ENVIRONMENT=production \
./bin/generate_dev_mode_dockerfiles.sh
$ MODE=build \
./bin/upgrade_containers.sh
Build and start the containers.
$ poetry run python -m tools.image_builder \
--dockerfiles-only \
--disable-cache-mounts \
--service celery \
--service redis \
--service test
$ docker compose \
-f docker-compose.test.yml up -d --build
Run the unit tests.
$ docker compose \
-f docker-compose.test.yml \
exec anthias-test bash ./bin/prepare_test_environment.sh -s
# Integration and non-integration tests should be run separately as the
# former doesn't run as expected when run together with the latter.
$ docker compose \
-f docker-compose.test.yml \
exec anthias-test ./manage.py test --exclude-tag=integration
$ docker compose \
-f docker-compose.test.yml \
exec anthias-test ./manage.py test --tag=integration
We've also provided a checklist that can serve as a guide for testing Anthias manually.
To get started, you need to start the development server first. See this section for details.
To start Webpack in development mode, run the following command:
$ docker compose -f docker-compose.dev.yml exec anthias-server \
npm run dev
Making changes to the CoffeeScript or SCSS files will automatically trigger a recompilation, generating the corresponding JavaScript and CSS files.
Just press Ctrl-C
to close Webpack in development mode.
The project uses ruff
for linting the Python codebase. While the linter is being run on the CI/CD pipeline,
you can also run it locally. There are several ways to do this.
act
lets you run GitHub Actions locally. This is useful for testing the CI/CD pipeline locally.
Installation instructions can be found here.
After installing and setting up act
, run the following command:
$ act -W .github/workflows/python-lint.yaml
The command above will run the linter on the all the Python files in the repository. If you want to run the linter on a specific file, you can try the commands in the next section.
You have to install Poetry first. You can find the installation instructions here.
After installing Poetry, run the following commands:
# Install the dependencies
$ poetry install --only=dev-host
$ poetry run ruff check .
To run the linter on a specific file, run the following command:
$ poetry run ruff check /path/to/file.py
Check what the latest release is:
$ git pull
$ git tag
# Running the `git tag` command should output something like this:
# 0.16
# ...
# v0.18.6
Create a new release:
$ git tag -a v0.18.7 -m "Test new automated disk images"
Push release:
$ git push origin v0.18.7
$ git tag -d v0.18.5 [±master ✓]
Deleted tag 'v0.18.5' (was 9b86c39)
$ git push --delete origin v0.18.5 [±master ✓]
In this section, we'll explain the different directories and files that are present in a Raspberry Pi with Anthias installed.
- All of the files and folders from the Github repo should be cloned into this directory.
default_assets.yml
— configuration file which contains the default assets that get added to the assets list if enabledinitialized
— tells whether access point service (for Wi-Fi connectivity) runs or notscreenly.conf
— configuration file for web interface settingsscreenly.db
– database file containing current assets information.
wifi-connect.service
— starts the Balenawifi-connect
program to dynamically set the Wi-Fi config on the device via the captive portalanthias-host-agent.service
— starts the Python scripthost_agent.py
, which subscribes from the Redis component and performs a system call to shutdown or reboot the device when the message is received.
sudoers
configuration file that allows pi user to execute certainsudo
commands without being a superuser (i.e.,root
)
anthias.plymouth
— Plymouth config file (sets module name,ImageDir
andScriptFile
dir)anthias.script
– plymouth script file that loads and scales the splash screen image during the boot processsplashscreen.png
— the spash screen image that is displayed during the boot process
export QT_LOGGING_DEBUG=1
export QT_LOGGING_RULES="*.debug=true"
export QT_QPA_EGLFS_DEBUG=1
The Anthias WebView is a custom-built web browser based on the Qt toolkit framework.
The browser is assembled with a Dockerfile and built by a webview/build_qt#.sh
script.
For further info on these files and more, visit the following link: https://github.com/Screenly/Anthias/tree/master/webview