diff --git a/.github/workflows/publish_docker_image.yml b/.github/workflows/publish_docker_image.yml new file mode 100644 index 0000000..4c4dd96 --- /dev/null +++ b/.github/workflows/publish_docker_image.yml @@ -0,0 +1,45 @@ +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registries: + name: Push Docker image to multiple registries + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: | + my-docker-hub-namespace/my-docker-hub-repository + ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore index 76b0d9f..340a09d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.yaml osc-mqtt-bridge +config/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7f7d697 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.20 + +# Build app +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY *.go ./ +RUN go build -o /osc-mqtt-bridge +WORKDIR /app +RUN rm -Rf /app; mkdir /etc/osc-mqtt-bridge + +# Configuration volume +VOLUME ["/etc/osc-mqtt-bridge"] + +# Command +CMD ["/osc-mqtt-bridge"] diff --git a/README.md b/README.md index 35523c3..75259cc 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ relays: mqtt_topic: osc/behringer_wing osc_host: 10.0.0.3 osc_port: 2223 - osc_bind_addr: 10.0.0.4 # Change to this machine's IP address. Expected to be a static IP. + osc_bind_addr: 0.0.0.0 log_level: 2 ``` @@ -40,7 +40,7 @@ relays: - `osc_port`: Port for OSC client connection. - `osc_bind_addr`: Bind address of the OSC server. - To have bidirectional mode, you must specify at least this, OscHost, and OscPort defined. You must specify the unicast IP address, cannot be `0.0.0.0`. + To have bidirectional mode, you must specify at least this, OscHost, and OscPort defined. - `osc_bind_port`: Port of the OSC server. Defaults to OscPort if specified. - `osc_disallow_arbritary_command`: Disallows pushing to arbritary commands to the cmd topic. @@ -92,4 +92,22 @@ go build ## Config file location -Same directory as the binary, in your home directory at `~/.config/mqtt-osc-bridge/config.yaml`, or under etc at `/etc/mqtt-osc-bridge/config.yaml`. +Same directory as the binary, in your home directory at `~/.config/osc-mqtt-bridge/config.yaml`, or under etc at `/etc/osc-mqtt-bridge/config.yaml`. + +## Docker +I have made docker images for this product as I use docker for home assistant in my environment and wanted to keep with the existing scheme for services that are used with home assistant. + +### Build Image +```bash +docker build --tag osc-mqtt-bridge . +``` + +### Run +```bash +docker run --volume ./config:/etc/osc-mqtt-bridge --publish 2223:2223/udp osc-mqtt-bridge +``` + +### Docker compose +```yaml + +``` \ No newline at end of file diff --git a/config.go b/config.go index b5a74a6..be9d370 100644 --- a/config.go +++ b/config.go @@ -24,8 +24,8 @@ func (a *App) ReadConfig() { // Configuration paths. localConfig, _ := filepath.Abs("./config.yaml") - homeDirConfig := usr.HomeDir + "/.config/mqtt-osc-bridge/config.yaml" - etcConfig := "/etc/mqtt-osc-bridge/config.yaml" + homeDirConfig := usr.HomeDir + "/.config/osc-mqtt-bridge/config.yaml" + etcConfig := "/etc/osc-mqtt-bridge/config.yaml" // Determine which configuration to use. var configFile string diff --git a/relay.go b/relay.go index 7f2c1aa..faeddbf 100644 --- a/relay.go +++ b/relay.go @@ -87,7 +87,6 @@ type Relay struct { OscPort int `yaml:"osc_port" json:"osc_port"` // OscBindAddr: Bind address of the OSC server. // To have bidirectional mode, you must specify at least this, OscHost, and OscPort defined. - // You must specify the unicast IP address, cannot be 0.0.0.0. OscBindAddr string `yaml:"osc_bind_addr" json:"osc_bind_addr"` // OscBindPort: Port of the OSC server. Defaults to OscPort if specified. OscBindPort int `yaml:"osc_bind_port" json:"osc_bind_port"`