From 63f8ede6882c026eac709441a3a401dae63337c4 Mon Sep 17 00:00:00 2001 From: robrotheram Date: Wed, 28 Feb 2024 23:50:51 +0000 Subject: [PATCH] Fix config not working in container --- app.sample.env | 6 +++--- docker-compose.yml | 29 +++++------------------------ go.mod | 2 +- main.go | 13 ++++++++++--- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/app.sample.env b/app.sample.env index e155f89..bc410b9 100755 --- a/app.sample.env +++ b/app.sample.env @@ -1,11 +1,11 @@ -SERVER_ADDRESS=0.0.0.0:8081 DISCORD_TOKEN=CHANGEME DISCORD_CLIENT_ID=CHANGEME DISCORD_CLIENT_SECRET=CHANGEME SESSION_SECRET=CHANGEME BASE_URL=http://localhost:8080 DEVELOPMENT=false -DISCORD_ENABLE_NOTIFICATIONS=true LISTEN_PORT=8080 LOG_LEVEL=info -DATABASE_PATH=/data \ No newline at end of file +DATABASE_PATH=/data +RESET=false +BETTER_STACK_TOKEN=OPTIONAL \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index eb4f44b..0190ad8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,19 @@ services: watch2gether: - image: ghcr.io/robrotheram/go-watch2gether:latest - restart: always - networks: - - caddy + build: + context: . environment: DISCORD_TOKEN: CHANGE_ME DISCORD_CLIENT_ID: CHANGE_ME DISCORD_CLIENT_SECRET: CHANGE_ME SESSION_SECRET: CHANGE_ME BASE_URL: https://watch2gether.exceptionerror.io - DEVELOPMENT: true - DISCORD_ENABLE_NOTIFICATIONS: false + DEVELOPMENT: 'true' + DISCORD_ENABLE_NOTIFICATIONS: 'false' LISTEN_PORT: 8080 LOG_LEVEL: info + RESET: 'true' DATABASE_PATH: "/data" volumes: - w2g_data:/data @@ -22,24 +21,6 @@ services: caddy: watch2gether.exceptionerror.io caddy.reverse_proxy: "{{upstreams 8080}}" - caddy: - image: lucaslorentz/caddy-docker-proxy:ci-alpine - ports: - - 80:80 - - 443:443 - environment: - - CADDY_INGRESS_NETWORKS=caddy - networks: - - caddy - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - caddy_data:/data - restart: unless-stopped - -networks: - caddy: - external: true - volumes: caddy_data: {} w2g_data: {} \ No newline at end of file diff --git a/go.mod b/go.mod index d486e3f..2e60a2f 100644 --- a/go.mod +++ b/go.mod @@ -10,10 +10,10 @@ require ( github.com/robrotheram/dca v0.0.0-20240103231016-764e174aecab github.com/segmentio/ksuid v1.0.4 github.com/sirupsen/logrus v1.9.3 + github.com/spf13/viper v1.18.2 golang.org/x/net v0.21.0 golang.org/x/oauth2 v0.17.0 gopkg.in/vansante/go-ffprobe.v2 v2.1.1 - github.com/spf13/viper v1.17.0 ) require ( diff --git a/main.go b/main.go index a8e1a03..813d318 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "os" "path/filepath" + "strings" "w2g/pkg/api" "w2g/pkg/controllers" "w2g/pkg/discord" @@ -34,12 +35,18 @@ func main() { log.Fatalf("Database Error: %v", err) } - log.Infof("Version: %s", utils.Version) + log.Infof("Version: %s", strings.TrimSuffix(utils.Version, "\r\n")) hub := controllers.NewHub(db) - bot, _ := discord.NewDiscordBot(utils.Configuration, hub) - bot.Start() + bot, err := discord.NewDiscordBot(utils.Configuration, hub) + if err != nil { + log.Warnf("discord bot error: %v", err) + } + err = bot.Start() + if err != nil { + log.Warnf("discord bot error: %v", err) + } defer bot.Close() app := api.NewApp(utils.Configuration, hub)