Skip to content

Commit

Permalink
feat: build lora_pkt_fwd
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinmarnold committed Oct 20, 2021
1 parent b5b4583 commit be291b9
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/compile-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Compile Docker Images

on: [push]

jobs:
main:
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: |
nebraltd/lora_gateway
ghcr.io/${{ github.repository }}
flavor: |
latest=true
tags: |
type=sha,prefix=
type=sha,format=long,prefix=
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Builds lora_pkt_fwd for each SPI bus and copies each to
# $OUTPUT_DIR/ respectively.

FROM balenalib/raspberry-pi-debian:buster-build as lora-pkt-fwd-sx1301-builder

ENV ROOT_DIR=/opt

# Build output of nebraltd/lora_gateway
ENV LORA_GATEWAY_OUTPUT_DIR=/opt/output

# Intermediary location files from LORA_GATEWAY_OUTPUT_DIR are copied to
ENV LORA_GATEWAY_INPUT_DIR="$ROOT_DIR/lora_gateway_builds"

# Location source files for nebraltd/packet_forwarder are copied to
ENV PACKET_FORWARDER_INPUT_DIR="$ROOT_DIR/packet_forwarder"

# Output built files to this location
ENV OUTPUT_DIR="$ROOT_DIR/output"

WORKDIR "$ROOT_DIR"

# Copy files into expected location
COPY . "$PACKET_FORWARDER_INPUT_DIR"
COPY --from=nebraltd/lora_gateway:9c4b1d0c79645c3065aa4c2f3019c14da6cb2675 "$LORA_GATEWAY_OUTPUT_DIR" "$LORA_GATEWAY_INPUT_DIR"

# Compile lora_pkt_fwd for all buses
RUN . "$PACKET_FORWARDER_INPUT_DIR/compile_lora_pkt_fwd.sh"
39 changes: 39 additions & 0 deletions compile_lora_pkt_fwd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env sh

compile_lora_pkt_fwd_for_spi_bus() {
spi_bus="$1"
echo "Compiling upstream lora_pkt_fwd for sx1301 on $spi_bus"

# lora_pkt_fwd Makefile expects lora_gateway to be to levels up
rm -rf "$ROOT_DIR/lora_gateway"
mkdir -p "$ROOT_DIR/lora_gateway"
cp -r "$LORA_GATEWAY_INPUT_DIR/$spi_bus/" "$ROOT_DIR/lora_gateway/libloragw/"

cd "$PACKET_FORWARDER_INPUT_DIR/lora_pkt_fwd" || exit
make clean
make -j 4

cp -R "$PACKET_FORWARDER_INPUT_DIR/lora_pkt_fwd/lora_pkt_fwd" "$OUTPUT_DIR/lora_pkt_fwd_$spi_bus"

echo "Finished building lora_pkt_fwd for sx1301 on $spi_bus in $OUTPUT_DIR"
}

compile_lora_pkt_fwd() {
echo "Compiling libloragw for sx1301 concentrator on all the necessary SPI buses in $ROOT_DIR"

# Built outputs will be copied to this directory
mkdir -p "$OUTPUT_DIR"

# In order to be more portable, intentionally not interating over an array
compile_lora_pkt_fwd_for_spi_bus spidev0.0
compile_lora_pkt_fwd_for_spi_bus spidev0.1
compile_lora_pkt_fwd_for_spi_bus spidev1.0
compile_lora_pkt_fwd_for_spi_bus spidev1.1
compile_lora_pkt_fwd_for_spi_bus spidev1.2
compile_lora_pkt_fwd_for_spi_bus spidev2.0
compile_lora_pkt_fwd_for_spi_bus spidev2.1
compile_lora_pkt_fwd_for_spi_bus spidev32766.0
}

compile_lora_pkt_fwd

0 comments on commit be291b9

Please sign in to comment.