Fix config path name, add dockerfile, add workflow.

This commit is contained in:
James Coleman 2023-04-23 10:46:37 -05:00
parent 40181226fb
commit f721728ebf
6 changed files with 94 additions and 6 deletions

View File

@ -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: |
grmrgecko/osc-mqtt-bridge
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 }}

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
config.yaml config.yaml
osc-mqtt-bridge osc-mqtt-bridge
config/

16
Dockerfile Normal file
View File

@ -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"]

View File

@ -12,7 +12,7 @@ relays:
mqtt_topic: osc/behringer_wing mqtt_topic: osc/behringer_wing
osc_host: 10.0.0.3 osc_host: 10.0.0.3
osc_port: 2223 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 log_level: 2
``` ```
@ -40,7 +40,7 @@ relays:
- `osc_port`: Port for OSC client connection. - `osc_port`: Port for OSC client connection.
- `osc_bind_addr`: Bind address of the OSC server. - `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_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. - `osc_disallow_arbritary_command`: Disallows pushing to arbritary commands to the cmd topic.
@ -92,4 +92,31 @@ go build
## Config file location ## 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
version: '2.3'
services:
postgres:
image: grmrgecko/osc-mqtt-bridge:latest
restart: unless-stopped
volumes:
- ./config:/etc/osc-mqtt-bridge
ports:
- "2223:2223/udp"
```

View File

@ -24,8 +24,8 @@ func (a *App) ReadConfig() {
// Configuration paths. // Configuration paths.
localConfig, _ := filepath.Abs("./config.yaml") localConfig, _ := filepath.Abs("./config.yaml")
homeDirConfig := usr.HomeDir + "/.config/mqtt-osc-bridge/config.yaml" homeDirConfig := usr.HomeDir + "/.config/osc-mqtt-bridge/config.yaml"
etcConfig := "/etc/mqtt-osc-bridge/config.yaml" etcConfig := "/etc/osc-mqtt-bridge/config.yaml"
// Determine which configuration to use. // Determine which configuration to use.
var configFile string var configFile string

View File

@ -87,7 +87,6 @@ type Relay struct {
OscPort int `yaml:"osc_port" json:"osc_port"` OscPort int `yaml:"osc_port" json:"osc_port"`
// OscBindAddr: Bind address of the OSC server. // OscBindAddr: Bind address of the OSC server.
// To have bidirectional mode, you must specify at least this, OscHost, and OscPort defined. // 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"` OscBindAddr string `yaml:"osc_bind_addr" json:"osc_bind_addr"`
// OscBindPort: Port of the OSC server. Defaults to OscPort if specified. // OscBindPort: Port of the OSC server. Defaults to OscPort if specified.
OscBindPort int `yaml:"osc_bind_port" json:"osc_bind_port"` OscBindPort int `yaml:"osc_bind_port" json:"osc_bind_port"`