From 81d1eec214d0f5414de47ccc398e8f2451b8352b Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Sun, 10 Dec 2023 15:23:41 -0500 Subject: [PATCH 01/12] investigating docker --- .dockerignore | 6 ++++++ Dockerfile | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9183d51 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git/ +README.md +.vscode/ +.dockerignore +README.md +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b3c2ce7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:alpine3.19 + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install -r requirements.txt + +COPY . . + +EXPOSE 5000 +ENV PORT 5000 + +CMD python stk_sweep.py \ No newline at end of file From 989578c79f07e99e7a5a9428d1630b1db4d98a79 Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO <32745243+PWRxPSYCHO@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:26:40 -0500 Subject: [PATCH 02/12] Create docker-image.yml --- .github/workflows/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..d657a63 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) From 156ecdc570906ccdd7c5e5473703c635afa18e11 Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Sun, 10 Dec 2023 16:08:01 -0500 Subject: [PATCH 03/12] testing more docker stuff --- Dockerfile | 9 +-------- README.md | 11 +++++++++++ docker-compose.yml | 11 +++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index b3c2ce7..d078658 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,6 @@ FROM python:alpine3.19 WORKDIR /app -COPY requirements.txt . - -RUN pip install -r requirements.txt - COPY . . -EXPOSE 5000 -ENV PORT 5000 - -CMD python stk_sweep.py \ No newline at end of file +RUN pip install -r requirements.txt \ No newline at end of file diff --git a/README.md b/README.md index d44624e..51f7796 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,17 @@ Before proceeding, ensure you have the following installed on your system: ``` Note: this currently starts the Flask development server. +## Docker + +TODO: Setup USB passthrough to access SDR devices + +Current draft Dockerfile and docker-compose.yml files have been added to the repo. + +To build and run application run the following command +```bash +docker compose run --publish 5000:5000 stk_sweep +``` + ## Usage After completing the setup, the Flask application will be running on your local server. You can access it via `localhost:5000/rtl_data`. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..82d4731 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.9' + +services: + stk_sweep: + image: sweep + ports: + - "5000:5000" + entrypoint: + - python + - stk_sweep.py + - --host=0.0.0.0 \ No newline at end of file From 6277e9040a9ddd34284ad2772d40bf892b3c518e Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO <32745243+PWRxPSYCHO@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:57:30 -0500 Subject: [PATCH 04/12] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 67044fe..220077c 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,6 @@ Before starting STK Sweep, make sure that you have the backend tools like rtl_tc ## Docker -TODO: Setup USB passthrough to access SDR devices - Current draft Dockerfile and docker-compose.yml files have been added to the repo. To build and run application run the following command From 5763b89f56d3c7a31f5d234b701cad95c5292e10 Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO <32745243+PWRxPSYCHO@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:00:24 -0500 Subject: [PATCH 05/12] Update docker-image.yml --- .github/workflows/docker-image.yml | 68 +++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d657a63..ab18cab 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,18 +1,72 @@ -name: Docker Image CI +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. on: push: - branches: [ "main" ] + branches: [ "master" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] pull_request: - branches: [ "main" ] + branches: [ "master" ] -jobs: +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + - name: Checkout repository + uses: actions/checkout@v3 + + # Setup buildx + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v1.7.0 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v1.14.1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4.0.1 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v2.10.0 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 5f6a8efb53fc3d18a2271d4bc6c33de2e62c5a07 Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Tue, 26 Dec 2023 15:24:56 -0500 Subject: [PATCH 06/12] updated dockerfile to be in sync with readme --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d078658..8a5ff6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ WORKDIR /app COPY . . -RUN pip install -r requirements.txt \ No newline at end of file +RUN python -m pip install -r requirements.txt \ No newline at end of file From c5e23d63b066cbb5c3d2980e339abbb626999132 Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Tue, 26 Dec 2023 15:25:09 -0500 Subject: [PATCH 07/12] added bash script to build and start container --- startContainer.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 startContainer.sh diff --git a/startContainer.sh b/startContainer.sh new file mode 100755 index 0000000..f0dcafd --- /dev/null +++ b/startContainer.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set x + +echo "Building Docker container..." + +docker build -t sweep . + +echo "Starting Docker container..." +docker compose run --publish 5000:5000 stk_sweep \ No newline at end of file From 851283bb81161830176d088ed3cf1e9277626b39 Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Tue, 26 Dec 2023 15:25:17 -0500 Subject: [PATCH 08/12] updated readme --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 220077c..93eaecf 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,15 @@ Before starting STK Sweep, make sure that you have the backend tools like rtl_tc ## Docker -Current draft Dockerfile and docker-compose.yml files have been added to the repo. +Dockerfile and docker-compose.yml files have been added to the repo. To build and run application run the following command ```bash -docker compose run --publish 5000:5000 stk_sweep +./startContainer.sh ``` +This bash script will build the docker image from the Docker file and then run the container from the docker compose file. + ## Usage After completing the setup, the Flask application will be running on your local server. You can access it via `localhost:5000/rtl_data`. From 66772197684b8cec7940883fdd55fbbcc34ad782 Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO <32745243+PWRxPSYCHO@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:27:21 -0500 Subject: [PATCH 09/12] Update docker-image.yml --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ab18cab..6c947ff 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,11 +7,11 @@ name: Docker on: push: - branches: [ "master" ] + branches: [ "main" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: - branches: [ "master" ] + branches: [ "main" ] env: # Use docker.io for Docker Hub if empty From a8960fdcadf1b2465be0b93db260d2de4c031624 Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Tue, 26 Dec 2023 15:39:41 -0500 Subject: [PATCH 10/12] updated docs --- README.md | 16 ++++++++++++++++ startContainer.sh | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 93eaecf..19e58c4 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,22 @@ To build and run application run the following command ./startContainer.sh ``` +Additionally, the Docker image is built with GitHub actions on the main branch. + +If you open up the docker-compose.yml and modify this line: + +```yml + image: sweep +``` + +to be + +```yml + image: ghcr.io/fosatech/stk-sweep:latest +``` + +Then run `docker compose run --publish 5000:5000 stk_sweep` to start the container + This bash script will build the docker image from the Docker file and then run the container from the docker compose file. ## Usage diff --git a/startContainer.sh b/startContainer.sh index f0dcafd..07f3d25 100755 --- a/startContainer.sh +++ b/startContainer.sh @@ -1,6 +1,6 @@ #!/bin/bash -set x +set -x echo "Building Docker container..." From dc4220deb86a993a1171143210ff4c014b1f19fc Mon Sep 17 00:00:00 2001 From: Script Tactics Date: Tue, 26 Dec 2023 15:41:17 -0500 Subject: [PATCH 11/12] updated docs --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 19e58c4..65f0aa1 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Before proceeding, ensure you have the following installed on your system: - `pip` + `virtualenv` - `rtl-sdr` package, including `rtl_tcp` and `rtl_power` - `hackrf_sweep` for the [HackRF](https://github.com/greatscottgadgets/hackrf) +- Optionally `docker` ## Installation and Setup From c5c930c18f05fc9e046bbc240258bf4f32aa4dd7 Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO Date: Thu, 4 Jan 2024 17:51:20 -0500 Subject: [PATCH 12/12] fixed docker integration --- Dockerfile | 4 ++-- README.md | 6 +++--- docker-compose.yml | 6 +++--- startContainer.sh | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a5ff6f..10a8e7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM python:alpine3.19 +FROM tiangolo/uwsgi-nginx-flask:python3.11-2024-01-01 WORKDIR /app COPY . . -RUN python -m pip install -r requirements.txt \ No newline at end of file +RUN pip3 install --no-cache-dir -r requirements.txt \ No newline at end of file diff --git a/README.md b/README.md index 9df910e..145bb4c 100644 --- a/README.md +++ b/README.md @@ -63,16 +63,16 @@ Additionally, the Docker image is built with GitHub actions on the main branch. If you open up the docker-compose.yml and modify this line: ```yml - image: sweep + image: raven ``` to be ```yml - image: ghcr.io/fosatech/stk-sweep:latest + image: ghcr.io/fosatech/raven:latest ``` -Then run `docker compose run --publish 5000:5000 stk_sweep` to start the container +Then run `docker compose run --publish 5000:5000 raven` to start the container This bash script will build the docker image from the Docker file and then run the container from the docker compose file. diff --git a/docker-compose.yml b/docker-compose.yml index 82d4731..4cd0e78 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,11 @@ version: '3.9' services: - stk_sweep: - image: sweep + raven: + image: raven ports: - "5000:5000" entrypoint: - python - - stk_sweep.py + - raven.py - --host=0.0.0.0 \ No newline at end of file diff --git a/startContainer.sh b/startContainer.sh index 07f3d25..0191726 100755 --- a/startContainer.sh +++ b/startContainer.sh @@ -4,7 +4,7 @@ set -x echo "Building Docker container..." -docker build -t sweep . +docker build -t raven . echo "Starting Docker container..." -docker compose run --publish 5000:5000 stk_sweep \ No newline at end of file +docker compose run --publish 5000:5000 raven \ No newline at end of file