diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml new file mode 100644 index 00000000..e6c04ea4 --- /dev/null +++ b/.github/workflows/build_image.yml @@ -0,0 +1,27 @@ +name: Build Docker Image + +on: + push: + branches: + - master + - feature/docker + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image for the Client + run: docker build . --file Dockerfile --target client --tag ghcr.io/janspeller/bw3-core/client:latest + - name: Build the Docker image for the Server + run: docker build . --file Dockerfile --target server --tag ghcr.io/janspeller/bw3-core/server:latest + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_PAT }} + - name: Push the Client Docker image to Github package repository + run: docker push ghcr.io/janspeller/bw3-core/client:latest + - name: Push the Server Docker image to Github package repository + run: docker push ghcr.io/janspeller/bw3-core/server:latest diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 index 8ac0c9fc..9e9193e8 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,45 @@ -FROM alpine:3.13 AS build-base -RUN apk add git make cmake g++ libusb-dev libpulse +FROM alpine:latest AS build-base +RUN apk add --no-cache git make cmake g++ libusb-dev libpulse FROM build-base AS rtl_fm -ARG RTL_SDR_VERSION=0.6.0 -RUN git clone --depth 1 --branch ${RTL_SDR_VERSION} https://github.com/osmocom/rtl-sdr.git /opt/rtl_sdr +RUN git clone --depth 1 https://gitea.osmocom.org/sdr/rtl-sdr.git /opt/rtl_sdr WORKDIR /opt/rtl_sdr/build RUN cmake .. && make +RUN make install FROM build-base AS multimon -ARG MULTIMON_VERSION=1.1.9 -RUN git clone --depth 1 --branch ${MULTIMON_VERSION} https://github.com/EliasOenal/multimon-ng.git /opt/multimon +RUN git clone --depth 1 https://github.com/EliasOenal/multimon-ng.git /opt/multimon WORKDIR /opt/multimon/build RUN cmake .. && make -FROM alpine:3.13 AS boswatch +FROM alpine:latest AS boswatch ARG BW_VERSION=develop RUN apk add git && \ git clone --depth 1 --branch ${BW_VERSION} https://github.com/BOSWatch/BW3-Core.git /opt/boswatch -FROM python:3.9.1-alpine AS runner -LABEL maintainer="bastian@schroll-software.de" +FROM python:alpine AS client +LABEL org.opencontainers.image.authors="info@schroll-it.de,jan@speller.biz" +LABEL org.opencontainers.image.source=https://github.com/janspeller/BW3-Core # for RTL for MM -RUN apk add libusb-dev libpulse && \ - pip3 install pyyaml +RUN apk add libusb-dev libpulse +RUN pip3 install pyyaml COPY --from=boswatch /opt/boswatch/ /opt/boswatch/ -COPY --from=multimon /opt/multimon/build/multimon-ng /opt/multimon-ng -COPY --from=rtl_fm /opt/rtl_sdr/build/src/ /opt/rtl_sdr +COPY --from=multimon /opt/multimon/build/multimon-ng /opt/multimon/multimon-ng +COPY --from=rtl_fm /usr/local/bin/rtl_fm /opt/rtl_sdr/rtl_fm +COPY --from=rtl_fm /usr/local/lib/librtlsdr.so.0 /usr/local/lib/librtlsdr.so.0 + +WORKDIR /opt/boswatch +CMD python3 /opt/boswatch/bw_client.py -c client.yaml + +FROM python:alpine AS server +LABEL org.opencontainers.image.authors="info@schroll-it.de,jan@speller.biz" +LABEL org.opencontainers.image.source=https://github.com/janspeller/BW3-Core + +RUN pip3 install pyyaml +COPY --from=boswatch /opt/boswatch/ /opt/boswatch/ +WORKDIR /opt/boswatch +CMD python3 /opt/boswatch/bw_server.py -c server.yaml +EXPOSE 8080 diff --git a/config/client.yaml b/config/client.yaml index 907e7fc1..2c852ed0 100644 --- a/config/client.yaml +++ b/config/client.yaml @@ -16,7 +16,7 @@ client: sendDelay: 3 # time in seconds to delay the resend try server: # only used if useBroadcast = no - ip: 127.0.0.1 + ip: 127.0.0.1 # use service name if you are running docker port: 8080 inputSource: @@ -27,7 +27,7 @@ inputSource: squelch: 1 gain: 100 #fir_size: 0 - rtlPath: /usr/local/bin/rtl_fm + rtlPath: /opt/rtl_sdr/rtl_fm lineIn: card: 1 device: 0 @@ -38,5 +38,5 @@ decoder: poc512: yes poc1200: yes poc2400: yes - Path: /opt/multimon/multimon-ng + path: /opt/multimon/multimon-ng char: DE diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..56614e82 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3' +services: + client: + image: ghcr.io/janspeller/bw3-core/client:latest + volumes: + - ./config:/opt/boswatch/config + - ./log:/opt/boswatch/log + devices: + - "/dev/bus/usb" + server: + image: ghcr.io/janspeller/bw3-core/server:latest + volumes: + - ./config:/opt/boswatch/config diff --git a/requirements.txt b/requirements.txt index 5e215ff0..8ea1afb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pyyaml # for documentation generating mkdocs -# for develope only +# for develop only pytest pytest-cov pytest-flake8