Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.github
data
*.png
coverage.*
*.out
spectogram
spectrogram
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,12 @@ jobs:

- name: Run tests
run: go test ./... -v

docker:
name: Docker Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Build image
run: docker build -t spectogram:ci .
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.24-alpine AS builder

WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY cmd/ ./cmd/
RUN CGO_ENABLED=0 go build -o /out/spectogram ./cmd/spectogram

FROM python:3.11-alpine

WORKDIR /app

COPY --from=builder /out/spectogram /usr/local/bin/spectogram
COPY web/ ./web/
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

EXPOSE 8000

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["serve"]
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ http://localhost:8000/web

You should now see an interactive, zoomable Plotly heatmap.

## 🐳 Running with Docker

A `Dockerfile` is included so you can run both steps without installing Go or Python locally. Build the image once:

```bash
docker build -t spectogram .
```

### Step 1. Generate the spectrogram data

Mount a local directory containing your audio file to `/app/data`, and generate the output into it:

```bash
docker run --rm -v "$(pwd)":/app/data spectogram generate -in /app/data/audio.mp3 -out /app/data/spectrogram.png -json /app/data/spectrogram.json
```

### Step 2. View the Spectrogram

Using the same mount, so the web viewer can find `spectrogram.json`:

```bash
docker run --rm -p 8000:8000 -v "$(pwd)":/app/data spectogram serve
```

Then open `http://localhost:8000/web` in your browser, same as the local workflow above.

## 🧠 How It Works?

The `Go` script:
Expand Down Expand Up @@ -106,10 +132,12 @@ Unit and integration tests live alongside the code in `cmd/spectogram/main_test.
## 📁 Folder Structure

```
.github/workflows/ - CI pipeline (build, vet, test)
.github/workflows/ - CI pipeline (build, vet, test, Docker image build)
cmd/spectogram/ - main Go application and tests (main.go, main_test.go)
web/ - HTML viewer with Plotly
data/ - generated spectrogram.json output (created automatically, not tracked in git)
Dockerfile - containerized build (Go binary + Python static file server)
docker-entrypoint.sh - dispatches `generate` and `serve` container commands
README.md - this file
go.mod - Go module info
```
Expand Down
15 changes: 15 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -e

case "$1" in
generate)
shift
exec spectogram "$@"
;;
serve)
exec python3 -m http.server 8000
;;
*)
exec "$@"
;;
esac