-
Notifications
You must be signed in to change notification settings - Fork 14
Add a github workflow to build and test the container #81
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
Open
dthaler
wants to merge
6
commits into
orcasound:main
Choose a base branch
from
dthaler:build-container-image
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3f1519f
Add a github workflow to build the container
dthaler 0b5eb2b
Use NODE_TYPE=dev-virt-s3 for github CI
dthaler dffcbe2
Add .dockerignore
dthaler 9e54472
Fix dev-virt-s3 to not require jackd
dthaler 95a646e
Test hls mode too
dthaler 77fd62c
Add build-container as a release branch
dthaler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Ignore environment files with secrets | ||
| .env | ||
| **/.env | ||
| *.env | ||
| node/.env | ||
| base/.env | ||
|
|
||
| # Ignore git repository | ||
| .git | ||
| .gitignore | ||
| .gitattributes | ||
|
|
||
| # Ignore node modules (if any) | ||
| **/node_modules | ||
|
|
||
| # Ignore security-sensitive files | ||
| **/*.pem | ||
| **/*.key | ||
| **/*.crt | ||
| **/*.p12 | ||
| **/*.pfx | ||
| **/*.jks | ||
|
|
||
| # Ignore backup and temporary files | ||
| **/*.bak | ||
| **/*.swp | ||
| **/*.swo | ||
| **/*~ | ||
| **/.DS_Store | ||
|
|
||
| # Ignore IDE and editor files | ||
| .vscode/ | ||
| .idea/ | ||
| *.code-workspace | ||
|
|
||
| # Ignore CI/CD artifacts (already in repo, but exclude from build context) | ||
| .github/ | ||
|
|
||
| # Ignore documentation | ||
| *.md | ||
| !node/README.md | ||
|
|
||
| # Keep .env.example (it's a template, not secrets) | ||
| !**/.env.example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| name: Build and Test Orcanode Container | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - container-release | ||
| tags: | ||
| - 'v*.*.*' # Trigger on version tags. | ||
| pull_request: | ||
| paths: | ||
| - 'node/**' | ||
| - 'base/**' | ||
| - '.github/workflows/build-container.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Build container image | ||
| run: docker build -t orcanode:test -f node/Dockerfile . | ||
|
|
||
| - name: Verify Python is available | ||
| run: docker run --rm orcanode:test python3 --version | ||
|
|
||
| - name: Verify FFmpeg is installed | ||
| run: docker run --rm orcanode:test ffmpeg -version | ||
|
|
||
| - name: Verify Jack audio is installed | ||
| run: docker run --rm orcanode:test which jackd | ||
|
|
||
| - name: Verify Python dependencies | ||
| run: docker run --rm orcanode:test python3 -c "import boto3; import inotify; print('Python deps OK')" | ||
|
|
||
| - name: Verify application scripts are present | ||
| run: docker run --rm orcanode:test ls -la /app/stream.sh | ||
|
|
||
| - name: Test container startup with dev-virt-s3 | ||
| run: | | ||
| # Copy .env.example to test.env and customize for CI. | ||
| cp node/.env.example test.env | ||
|
|
||
| # Replace FILLTHISIN placeholders with test values. | ||
| sed -i 's/AWS_ACCESS_KEY_ID=FILLTHISIN/AWS_ACCESS_KEY_ID=test-key-id/g' test.env | ||
| sed -i 's/AWS_SECRET_ACCESS_KEY=FILLTHISIN/AWS_SECRET_ACCESS_KEY=test-secret/g' test.env | ||
| sed -i 's/key="FILLTHISIN"/key="test-logdna-key"/g' test.env | ||
| sed -i 's/NODE_NAME=rpi_location/NODE_NAME=rpi_github_ci/g' test.env | ||
|
|
||
| # Use dev-virt-s3 mode for CI (no audio hardware required). | ||
| sed -i 's/NODE_TYPE=hls-only/NODE_TYPE=dev-virt-s3/g' test.env | ||
| sed -i 's/NODE_LOOPBACK=true/NODE_LOOPBACK=false/g' test.env | ||
|
|
||
| # Start container with env file. | ||
| docker run -d --name orcanode-test-virt \ | ||
| --env-file test.env \ | ||
| orcanode:test | ||
|
|
||
| sleep 10 | ||
| echo "=== Container logs ===" | ||
| docker logs orcanode-test-virt | ||
|
|
||
| # Check container health: accept running or cleanly exited (exit code 0). | ||
| STATUS=$(docker inspect --format='{{.State.Status}}' orcanode-test-virt) | ||
| EXIT_CODE=$(docker inspect --format='{{.State.ExitCode}}' orcanode-test-virt) | ||
|
|
||
| echo "Container status: $STATUS, exit code: $EXIT_CODE" | ||
|
|
||
| if [ "$STATUS" = "running" ]; then | ||
| echo "Container is running" | ||
|
|
||
| # Verify HLS segments are being generated. | ||
| docker exec orcanode-test-virt ls -la /tmp/rpi_github_ci/hls/ | ||
|
|
||
| echo "Container is generating HLS stream" | ||
| elif [ "$STATUS" = "exited" ] && [ "$EXIT_CODE" = "0" ]; then | ||
| echo "Container exited cleanly (exit code 0)" | ||
| else | ||
| echo "Container failed with status: $STATUS, exit code: $EXIT_CODE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker stop orcanode-test-virt || true | ||
| docker rm orcanode-test-virt | ||
| rm test.env | ||
|
|
||
| - name: Test container startup with hls-only (hardware path) | ||
| run: | | ||
| # Copy .env.example to test.env and customize for CI. | ||
| cp node/.env.example test.env | ||
|
|
||
| # Replace FILLTHISIN placeholders with test values. | ||
| sed -i 's/AWS_ACCESS_KEY_ID=FILLTHISIN/AWS_ACCESS_KEY_ID=test-key-id/g' test.env | ||
| sed -i 's/AWS_SECRET_ACCESS_KEY=FILLTHISIN/AWS_SECRET_ACCESS_KEY=test-secret/g' test.env | ||
| sed -i 's/key="FILLTHISIN"/key="test-logdna-key"/g' test.env | ||
| sed -i 's/NODE_NAME=rpi_location/NODE_NAME=rpi_github_ci_hw/g' test.env | ||
|
|
||
| # Keep default NODE_TYPE=hls-only (tests hardware audio path) | ||
|
|
||
| # Start container with env file. | ||
| docker run -d --name orcanode-test-hw \ | ||
| --env-file test.env \ | ||
| orcanode:test | ||
|
|
||
| sleep 5 | ||
| echo "=== Container logs (hls-only mode) ===" | ||
| docker logs orcanode-test-hw | ||
|
|
||
| # Check container health | ||
| STATUS=$(docker inspect --format='{{.State.Status}}' orcanode-test-hw) | ||
| EXIT_CODE=$(docker inspect --format='{{.State.ExitCode}}' orcanode-test-hw) | ||
|
|
||
| echo "Container status: $STATUS, exit code: $EXIT_CODE" | ||
|
|
||
| if [ "$STATUS" = "running" ]; then | ||
| echo "✓ Container is running (hls-only mode, audio hardware errors expected)" | ||
| elif [ "$STATUS" = "exited" ] && [ "$EXIT_CODE" = "0" ]; then | ||
| echo "✓ Container exited cleanly (exit code 0)" | ||
| else | ||
| echo "✗ Container failed with status: $STATUS, exit code: $EXIT_CODE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker stop orcanode-test-hw || true | ||
| docker rm orcanode-test-hw | ||
| rm test.env | ||
|
|
||
| build-and-push: | ||
| needs: test | ||
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/container-release' || github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| actions: write # Required for cache-to: type=gha | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 | ||
| with: | ||
| images: ghcr.io/${{ github.repository }}/orcanode | ||
| tags: | | ||
| # Semver tags on release | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=semver,pattern={{major}} | ||
| type=ref,event=tag | ||
| # Branch-based tags | ||
| type=ref,event=branch | ||
| type=sha | ||
| # Latest tag for main branch | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| - name: Build and push multi-arch images | ||
| uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 | ||
| with: | ||
| context: . | ||
| file: ./node/Dockerfile | ||
| platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| .env | ||
| .env | ||
| .vs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Orcanode Configuration Template | ||
| # Copy this file to .env and customize for your deployment | ||
| # See README.md for detailed field descriptions | ||
|
|
||
| # === AWS Credentials === | ||
| # Get these from AWS IAM Console or contact Orcasound admin | ||
| AWS_ACCESS_KEY_ID=FILLTHISIN | ||
| AWS_SECRET_ACCESS_KEY=FILLTHISIN | ||
|
|
||
| # === AWS Configuration === | ||
| AWS_METADATA_SERVICE_TIMEOUT=5 | ||
| AWS_METADATA_SERVICE_NUM_ATTEMPTS=0 | ||
| REGION=us-west-2 | ||
|
|
||
| # === S3 Bucket Selection === | ||
| BUCKET_TYPE=dev | ||
| #BUCKET_TYPE=prod | ||
|
|
||
|
dthaler marked this conversation as resolved.
|
||
| # === Node Configuration === | ||
| # Uncomment the NODE_TYPE you need: | ||
| NODE_TYPE=hls-only | ||
| #NODE_TYPE=research | ||
| #NODE_TYPE=debug | ||
| #NODE_TYPE=dev-virt-s3 | ||
|
|
||
| # Unique identifier for this node (format: rpi_location) | ||
| NODE_NAME=rpi_location | ||
|
|
||
| # Audio loopback for testing (true/false/hls) | ||
| # - true: Route audio input directly to output via Jack | ||
| # - false: No loopback | ||
| # - hls: Play back the generated HLS stream with ffplay (for testing) | ||
| NODE_LOOPBACK=true | ||
| #NODE_LOOPBACK=false | ||
| #NODE_LOOPBACK=hls | ||
|
|
||
| # Audio Settings | ||
| SAMPLE_RATE=48000 | ||
| AUDIO_HW_ID=pisound | ||
| CHANNELS=1 | ||
|
|
||
| # === Logging Configuration === | ||
| # Used by logspout sidecar - get credentials from Orcasound admin | ||
| SYSLOG_URL=syslog://syslog-a.logdna.com:37043 | ||
| SYSLOG_STRUCTURED_DATA='logdna@48950 key="FILLTHISIN" tag="docker"' | ||
|
|
||
| # === Stream Configuration === | ||
| FLAC_DURATION=30 | ||
| SEGMENT_DURATION=10 | ||
|
|
||
| # === System Configuration === | ||
| LC_ALL=C.UTF-8 | ||
|
|
||
| # === Field Descriptions === | ||
| # | ||
| # AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY: | ||
| # AWS credentials for S3 bucket access | ||
| # | ||
| # BUCKET_TYPE: | ||
| # - dev: Development bucket (dev-streaming-orcasound-net) | ||
| # - prod: Production bucket (audio-orcasound-net) | ||
| # - custom: Use custom buckets (requires BUCKET_STREAMING and BUCKET_ARCHIVE) | ||
| # | ||
| # NODE_TYPE: | ||
| # - hls-only: Stream HLS segments only (most common) | ||
| # - research: Stream HLS + archive FLAC files | ||
| # - debug: Stream DASH via mpegts for debugging (requires test-engine-live-tools) | ||
| # - dev-virt-s3: Development mode using sample WAV file (no audio hardware required) | ||
| # | ||
| # NODE_NAME: | ||
| # Unique identifier in format: rpi_location (e.g., rpi_bush_point, rpi_port_townsend) | ||
| # | ||
| # AUDIO_HW_ID: | ||
| # Sound card identifier. Find with: arecord -l | ||
| # Use logical name (pisound, USB) not device numbers (0,0) | ||
| # | ||
| # SAMPLE_RATE: | ||
| # Audio sampling rate in Hz (48000 for standard, 192000 for research) | ||
| # | ||
| # CHANNELS: | ||
| # Number of audio channels (1=mono, 2=stereo) | ||
| # | ||
| # SEGMENT_DURATION: | ||
| # Seconds per HLS segment (typically 10) | ||
| # | ||
| # FLAC_DURATION: | ||
| # Seconds per archived FLAC file (research mode only, typically 30) | ||
| # | ||
| # SYSLOG_URL / SYSLOG_STRUCTURED_DATA: | ||
| # LogDNA/Mezmo credentials for centralized logging via logspout | ||
| # Request credentials in #hydrophone-nodes on Orcasound Slack | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Environment variables with secrets | ||
| .env | ||
|
|
||
| # But keep the example | ||
| !.env.example |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 227
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 290
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 87
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 186
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 2092
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 1719
🏁 Script executed:
Repository: orcasound/orcanode
Length of output: 2446
Simplify the image path by removing the redundant
/orcanodesuffix.The image path
ghcr.io/${{ github.repository }}/orcanoderesolves toghcr.io/orcasound/orcanode/orcanode, which is redundant since only a single container image is built in this workflow. Use:This produces the simpler and more conventional image path
ghcr.io/orcasound/orcanode.🤖 Prompt for AI Agents