Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future3/better logging #2139

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/test_docker_debian_codename_sub_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ on:
debian_codename:
required: true
type: string
platform:
required: true
type: string
docker_image_name:
required: false
type: string
default: rpi-jukebox-rfid-v3
platform:
required: false
type: string
default: linux/arm/v7
cache_scope:
required: false
type: string
Expand All @@ -34,7 +33,7 @@ env:
# let only one instance run the test so cache is not corrupted.
# cancel already running instances as only the last run will be relevant
concurrency:
group: ${{ inputs.cache_scope }}-${{ inputs.debian_codename }}
group: ${{ inputs.cache_scope }}-${{ inputs.debian_codename }}-${{ inputs.platform }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -73,10 +72,12 @@ jobs:
DEBIAN_CODENAME: ${{ inputs.debian_codename }}
DOCKER_IMAGE_NAME: ${{ inputs.docker_image_name }}
CACHE_SCOPE: ${{ inputs.cache_scope }}
PLATFORM: ${{ inputs.platform }}
run: |
echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-test" >> $GITHUB_OUTPUT
echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}.tar" >> $GITHUB_OUTPUT
echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}" >> $GITHUB_OUTPUT
PLATFORM=${PLATFORM////_}
echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-${PLATFORM}-test" >> $GITHUB_OUTPUT
echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}.tar" >> $GITHUB_OUTPUT
echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}" >> $GITHUB_OUTPUT

- name: Set Output vars
id: vars
Expand Down Expand Up @@ -143,7 +144,7 @@ jobs:
strategy:
fail-fast: false
matrix:
test_script: ['run_install_common.sh', 'run_install_faststartup.sh', 'run_install_webapp_local.sh', 'run_install_webapp_download.sh']
test_script: ['run_install_common.sh', 'run_install_faststartup.sh', 'run_install_webapp_local.sh', 'run_install_webapp_download.sh', 'run_install_libzmq_local.sh']

steps:
- name: Set up QEMU
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test_docker_debian_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ concurrency:
jobs:

# Build container and run tests. Duplication of job intended for better visualization.
run_bookworm:
name: 'bookworm'
run_bookworm_armv7:
name: 'bookworm armv7'
uses: ./.github/workflows/test_docker_debian_codename_sub_v3.yml
with:
debian_codename: 'bookworm'
platform: linux/arm/v7

run_bullseye:
name: 'bullseye'
run_bullseye_armv7:
name: 'bullseye armv7'
uses: ./.github/workflows/test_docker_debian_codename_sub_v3.yml
with:
debian_codename: 'bullseye'
platform: linux/arm/v7
40 changes: 40 additions & 0 deletions ci/installation/run_install_libzmq_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

# Install Phoniebox and test it
# Used e.g. for tests on Docker

# Objective:
# Test for the libzmq local build (no precompiled download)

SOURCE="${BASH_SOURCE[0]}"
SCRIPT_DIR="$(dirname "$SOURCE")"
LOCAL_INSTALL_SCRIPT_PATH="${INSTALL_SCRIPT_PATH:-${SCRIPT_DIR}/../../installation}"
LOCAL_INSTALL_SCRIPT_PATH="${LOCAL_INSTALL_SCRIPT_PATH%/}"

export BUILD_LIBZMQ_WITH_DRAFTS_ON_DEVICE=true
# Run installation (in interactive mode)
# y - start setup
# n - use static ip
# n - deactivate ipv6
# n - setup autohotspot
# n - deactivate bluetooth
# n - disable on-chip audio
# - - mpd overwrite config (only with existing installation)
# n - setup rfid reader
# n - setup samba
# n - setup webapp
# - - setup kiosk mode (only with webapp = y)
# - - install node (only with webapp = y)
# n - reboot

"${LOCAL_INSTALL_SCRIPT_PATH}/install-jukebox.sh" <<< 'y
n
n
n
n
n
n
n
n
n
'
15 changes: 12 additions & 3 deletions docker/jukebox.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM debian:bullseye-slim

# Prepare Raspberry Pi like environment

# These are only dependencies that are required to get as close to the
# Raspberry Pi environment as possible.
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -36,7 +34,18 @@ WORKDIR ${HOME}
COPY --chown=${USER}:${USER} . ${INSTALLATION_PATH}/

RUN pip install --no-cache-dir -r ${INSTALLATION_PATH}/requirements.txt
RUN pip install pyzmq

ENV ZMQ_TMP_DIR libzmq
ENV ZMQ_VERSION 4.3.5
ENV ZMQ_PREFIX /usr/local

RUN [ "$(uname -m)" = "aarch64" ] && ARCH="arm64" || ARCH="$(uname -m)"; \
wget https://github.com/pabera/libzmq/releases/download/v${ZMQ_VERSION}/libzmq5-${ARCH}-${ZMQ_VERSION}.tar.gz -O libzmq.tar.gz; \
tar -xzf libzmq.tar.gz -C ${ZMQ_PREFIX}; \
rm -f libzmq.tar.gz;

RUN export ZMQ_PREFIX=${PREFIX} && export ZMQ_DRAFT_API=1
RUN pip install -v --no-binary pyzmq --pre pyzmq

EXPOSE 5555 5556

Expand Down
19 changes: 15 additions & 4 deletions documentation/developers/known-issues.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# Known Issues

## Browsers
## Installing `libzmq` in Docker fails

The Web UI will **not** work with Firefox, due to an issue with websockets and pyzmq. Please use a different
browser for now.
To speed up the Docker build process, we are distributing pre-build versions of libzmq with drafts flag at the latest version. In case the download fails because the respective architecture build does not exist, you can build the version yourself.

Add `build-essential` to be installed additionally with `apt-get`. Additionally, replace the command to download the pre-built library with the following command.

```
# Compile ZMQ
RUN cd ${HOME} && mkdir ${ZMQ_TMP_DIR} && cd ${ZMQ_TMP_DIR}; \
wget https://github.com/zeromq/libzmq/releases/download/v${ZMQ_VERSION}/zeromq-${ZMQ_VERSION}.tar.gz -O libzmq.tar.gz; \
tar -xzf libzmq.tar.gz; \
rm -f libzmq.tar.gz; \
zeromq-${ZMQ_VERSION}/configure --prefix=${ZMQ_PREFIX} --enable-drafts; \
make && make install
```

## Configuration

In `jukebox.yaml` (and all other config files):
In `jukebox.yaml` (and all other config files):
Always use relative path from settingsfile `../../`, but do not use relative paths with `~/`.

**Sole** exception is in `playermpd.mpd_conf`.
68 changes: 68 additions & 0 deletions documentation/developers/libzmq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# `libzmq` for Raspberry Pi

## `libzmp` Releases

The Jukebox requires `libzmq` to work properly. We provide downloadable builds to speed up the installation process of the Phoniebox.

* https://github.com/pabera/libzmq/releases

> [!NOTE]
> We can't use stable builds that are distributed by [zeromq](https://github.com/zeromq/libzmq/releases) directly because the Jukebox requires draft builds to support WebSockets. These [draft builds](https://pyzmq.readthedocs.io/en/latest/howto/draft.html) are not officially provided through zeromq for Raspberry Pi architecture (e.g. `armv6` or `armv7`).

## Building `libzmp`

If you need to update the `libzmq` version in the future, follow these steps.

### Install Cross-Compilation Environment

First, you need to install Dockcross. Dockcross provides Docker images for cross-compilation.

1. **Pull the Dockcross Image**: For Raspberry Pi B, 4 or Zero 2 we need `linux-armv7`, for older models `linux-armv6`. The following example shows how to compile for `armv7` (32 bit, `arm32v7`). If you want to compile for another target, change the commands accordingly. For Docker Development environments, other targets like `arm64` or `x86_64` become relevant.

```bash
docker pull dockcross/linux-armv7
```

3. **Create a Dockcross Script**: After pulling the image, you create a Dockcross script which will be used to run the cross-compilation tools in the Docker container.

```bash
docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7
chmod +x ./dockcross-linux-armv7
```

This command creates a script named `dockcross-linux-armv7` in your current directory.

### Cross-Compiling libzmq

With Dockcross installed, you can now modify your `libzmq` compilation process to use the Dockcross environment.

1. **Download `libzmq` Source**: Similar to your original process, download the `libzmq` source code:

```bash
ZMQ_VERSION=4.3.5
wget https://github.com/zeromq/libzmq/releases/download/v${ZMQ_VERSION}/zeromq-${ZMQ_VERSION}.tar.gz -O libzmq.tar.gz
tar -xzf libzmq.tar.gz
```

2. **Cross-Compilation using Dockcross**:

Modify your build process to run inside the Dockcross environment:

```bash
./dockcross-linux-armv7 bash -c '\
cd zeromq-${ZMQ_VERSION} && \
./configure --prefix=/usr/local --enable-drafts && \
make -j$(nproc) && \
make install DESTDIR=$(pwd)/../installed'
```

> [!NOTE]
> In the script above, you need to update ${ZMQ_VERSION} to the actual value as the script does not jave access to your host machine ENV variables.

This command configures and builds `libzmq` inside the Docker container. The `DESTDIR` variable is used to specify where to install the files inside the container.

3. **Compress the Compiled Binaries**: After compilation, the binaries are located in the `installed` directory inside your `zeromq-${ZMQ_VERSION}` directory.

```
tar -czvf libzmq5-armv7-${ZMQ_VERSION}.tar.gz -C installed/usr/local --exclude='.' include lib
```
20 changes: 16 additions & 4 deletions installation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
## Logging - Bash Script output rules

```bash
Output to both console and logfile: "$ command | tee /dev/fd/3"
Output to console only "$ command 1>&3"
Output to logfile only: "$ command"
No output to both console and logfile: "$ command > /dev/null"
print_lc "This message will be logged to both console and logfile"
print_c "This message will only be logged to the console"
log "This message will only be logged to the logfile"
clear 1>&3
```




[Learn more about bash script outputs](https://stackoverflow.com/questions/18460186/writing-outputs-to-log-file-and-console)

## Installation

[Install Phoniebox software](../documentation/builders/installation.md#install-phoniebox-software)








1>&3
2 changes: 1 addition & 1 deletion installation/includes/01_default_config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

BUILD_LIBZMQ_WITH_DRAFTS_ON_DEVICE=false
BUILD_LIBZMQ_WITH_DRAFTS_ON_DEVICE=${BUILD_LIBZMQ_WITH_DRAFTS_ON_DEVICE:-"false"}
ENABLE_STATIC_IP=true
DISABLE_IPv6=true
ENABLE_AUTOHOTSPOT=false
Expand Down
Loading