From 20da06ab91351cc0e745c44cc38164fa6a49efc4 Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Wed, 4 May 2022 23:42:44 +0200 Subject: [PATCH] Update Dockerfile, add Build for Images, change docker-compose to use images --- .github/workflows/build_image.yml | 20 +++++++++++--------- Dockerfile | 23 +++++++++++++++-------- docker-compose.yaml | 11 ++--------- docker/localdev/Server.Dockerfile | 13 ------------- requirements.txt | 2 +- 5 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 docker/localdev/Server.Dockerfile diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index f1742bd..9af7818 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -12,14 +12,16 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag boswatch:latest + - name: Build the Docker image for the Client + run: docker build . --file Dockerfile --target client --tag docker.pkg.github.com/janspeller/bw3-core/client:latest + - name: Build the Docker image for the Server + run: docker build . --file Dockerfile --target server --tag docker.pkg.github.com/janspeller/bw3-core/server:latest - name: docker login env: - GH_PACKAGES_USERNAME: ${{ secrets.GH_PACKAGES_USERNAME }} - GH_PACKAGES_PASSWORD: ${{ secrets.GH_PACKAGES_PASSWORD }} - run: docker login docker.pkg.github.com --username $GH_PACKAGES_USERNAME --password $GH_PACKAGES_PASSWORD - - name: Rename the Docker image - run: docker tag boswatch docker.pkg.github.com/janspeller/bw3-core/boswatch:latest - - name: Push the Docker image to Github package repository - run: docker push docker.pkg.github.com/BOSWatch/bw3-core/boswatch:latest + GH_USERNAME: ${{ secrets.GH_USERNAME }} + GH_PAT: ${{ secrets.GH_PAT }} + run: echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin + - name: Push the Client Docker image to Github package repository + run: docker push docker.pkg.github.com/BOSWatch/bw3-core/client:latest + - name: Push the Server Docker image to Github package repository + run: docker push docker.pkg.github.com/BOSWatch/bw3-core/se4rver:latest diff --git a/Dockerfile b/Dockerfile index 2cc71ba..945a804 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,23 @@ -FROM alpine:3.10 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 FROM build-base AS multimon -ARG MULTIMON_VERSION=1.1.8 -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.10 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.6-alpine AS runner +FROM python:alpine AS boswatch-base LABEL maintainer="bastian@schroll-software.de" # for RTL for MM @@ -27,5 +25,14 @@ RUN apk add libusb-dev libpulse && \ pip3 install pyyaml COPY --from=boswatch /opt/boswatch/ /opt/boswatch/ +RUN mkdir /opt/boswatch/log COPY --from=multimon /opt/multimon/build/multimon-ng /opt/multimon/multimon-ng COPY --from=rtl_fm /opt/rtl_sdr/build/src/ /opt/rtl_sdr/ +WORKDIR /opt/boswatch + +FROM boswatch-base AS client +CMD python3 /opt/boswatch/bw_client.py -c client.yaml + +FROM boswatch-base AS server +CMD python3 /opt/boswatch/bw_server.py -c server.yaml +EXPOSE 8080 diff --git a/docker-compose.yaml b/docker-compose.yaml index f003223..4e7e07d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,15 +1,8 @@ version: '3' services: client: - build: - dockerfile: docker/localdev/Client.Dockerfile - context: . - command: python /opt/boswatch/bw_client.py -c client.yaml + image: docker.pkg.github.com/janspeller/bw3-core/client:latest devices: - "/dev/bus/usb" server: - build: - dockerfile: docker/localdev/Server.Dockerfile - context: . - command: python /opt/boswatch/bw_server.py -c server.yaml - + image: docker.pkg.github.com/janspeller/bw3-core/server:latest diff --git a/docker/localdev/Server.Dockerfile b/docker/localdev/Server.Dockerfile deleted file mode 100644 index e8f284f..0000000 --- a/docker/localdev/Server.Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM alpine:3.10 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.6-alpine AS runner -LABEL maintainer="bastian@schroll-software.de" - -RUN pip3 install pyyaml - -RUN mkdir /log/ -COPY --from=boswatch /opt/boswatch/ /opt/boswatch/ -COPY ./config/* /opt/boswatch/config/ diff --git a/requirements.txt b/requirements.txt index 5e215ff..8ea1afb 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