Skip to content

Commit

Permalink
Refactors wifi-connect structure
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetersson committed Feb 17, 2023
1 parent ba4302b commit 588b2fe
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 33 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ Anthias works on all Raspberry Pi versions, including Raspberry Pi Zero, Raspber

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.

Do note that Anthias is using Docker's [buildx](https://docs.docker.com/engine/reference/commandline/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:

```bash
./bin/build_containers.sh
$ docker-compose \
-f docker-compose.dev.yml up
```
Expand All @@ -65,13 +68,15 @@ $ docker-compose \
Start the containers.

```bash
$ ./bin/build_containers.sh
$ docker-compose \
-f docker-compose.test.yml up -d
```

Run the unit tests.

```bash
$ ./bin/build_containers.sh
$ docker-compose \
-f docker-compose.test.yml \
exec -T srly-ose-test bash ./bin/prepare_test_environment.sh -s
Expand Down
7 changes: 4 additions & 3 deletions balena.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ post-provisioning: >-
With Anthias, a monitor/TV and a Raspberry Pi, you can create a remotely managed screen that can display:
- images
- video
- web pages
* Images
* Video
* Web pages
* Video feeds (RTSP)
Thanks to Balena [OpenFleets](https://hub.balena.io/organizations/screenly_ose/fleets), you benefit from having automatic updates. As soon as updates are shipped, they will be deployed to your device.
Expand Down
26 changes: 21 additions & 5 deletions bin/build_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export GIT_SHORT_HASH=$(git rev-parse --short HEAD)
export GIT_HASH=$(git rev-parse HEAD)
export BASE_IMAGE_TAG=buster
export DEBIAN_VERSION=buster
export QT_VERSION=5.15.2
export WEBVIEW_GIT_HASH=0b6d49359133246659b9ba1d8dd883e3fc5c9a91
export WEBVIEW_BASE_URL="https://github.com/Screenly/Anthias/releases/download/WebView-v0.2.1"
export CHROME_DL_URL="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_107.0.5304.121-1_amd64.deb"
export CHROMEDRIVER_DL_URL="https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_linux64.zip"

DOCKER_BUILD_ARGS=("buildx" "build" "--load")
echo 'Make sure you ran `docker buildx create --use` before the command'
Expand Down Expand Up @@ -56,6 +51,27 @@ fi
for container in server celery redis websocket nginx viewer wifi-connect 'test'; do
echo "Building $container"

if [ "$container" == 'viewer' ]; then
export QT_VERSION=5.15.2
export WEBVIEW_GIT_HASH=0b6d49359133246659b9ba1d8dd883e3fc5c9a91
export WEBVIEW_BASE_URL="https://github.com/Screenly/Anthias/releases/download/WebView-v0.2.1"
export CHROME_DL_URL="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_107.0.5304.121-1_amd64.deb"
export CHROMEDRIVER_DL_URL="https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_linux64.zip"

elif [ "$container" == 'wifi-connect' ]; then
# Logic for determining the correct architecture for the wifi-connect container
if [ "$TARGET_PLATFORM" = 'linux/arm/v6' ]; then
architecture=rpi
else
architecture=armv7hf
fi

wc_download_url='https://api.github.com/repos/balena-os/wifi-connect/releases/45509064'
jq_filter=".assets[] | select (.name|test(\"linux-$architecture\")) | .browser_download_url"
archive_url=$(curl -sL "$wc_download_url" | jq -r "$jq_filter")
export ARCHIVE_URL="$archive_url"
fi

# For all but redis and nginx, and viewer append the base layer
if [ ! "$container" == 'redis' ] || [ ! "$container" == 'nginx' ] || [ ! "$container" == 'viewer' ]; then
cat "docker/Dockerfile.base.tmpl" | envsubst > "docker/Dockerfile.$container"
Expand Down
15 changes: 0 additions & 15 deletions bin/install_wifi_connect.sh

This file was deleted.

4 changes: 2 additions & 2 deletions docker/Dockerfile.base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ RUN --mount=type=cache,target=/var/cache/apt \
libcec-dev \
libffi-dev \
libraspberrypi0 \
libraspberrypi0 \
libssl-dev \
libzmq3-dev \
lsb-release \
libraspberrypi0 \
omxplayer \
mplayer \
net-tools \
omxplayer \
procps \
psmisc \
python-dev \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.viewer.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.3
# syntax=docker/dockerfile:1.4
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}

# This list needs to be trimmed back later
Expand Down
10 changes: 3 additions & 7 deletions docker/Dockerfile.wifi-connect.tmpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get -y install --no-install-recommends \
dnsmasq \
jq \
wget \
wireless-tools

WORKDIR /usr/src/app

ARG TARGET_PLATFORM

COPY ./bin/install_wifi_connect.sh .
RUN bash ./install_wifi_connect.sh
RUN curl -sL -o /tmp/wifi_connect.tgz "$ARCHIVE_URL" && \
tar xfz /tmp/wifi_connect.tgz -C /usr/src/app && \
rm /tmp/wifi_connect.tgz

COPY requirements/requirements.wifi-connect.txt /tmp/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
Expand Down

0 comments on commit 588b2fe

Please sign in to comment.