From 77768ff43107d1626d1224541d964a80326772b0 Mon Sep 17 00:00:00 2001 From: Artyom Belousov Date: Sun, 28 May 2023 00:04:30 +0300 Subject: [PATCH] Add port environment variable --- cmd/bot/main.go | 8 +++++++- docker-compose.yaml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/bot/main.go b/cmd/bot/main.go index 6be8986..1252dd4 100644 --- a/cmd/bot/main.go +++ b/cmd/bot/main.go @@ -28,6 +28,7 @@ type config struct { vkToken string vkConfirmationString string ydbConnectionString string + port string } func getConfig() *config { @@ -69,6 +70,11 @@ func getConfig() *config { panic("YDB_CONNECTION_STRING environment variable not defined") } + cfg.port, exists = os.LookupEnv("PORT") + if !exists { + panic("PORT environment variable not defined") + } + return &cfg } @@ -132,5 +138,5 @@ func main() { r.POST("vk", handler.HandleMessage) r.POST("tg", tgHandler.HandleMessage) - _ = r.Run(":8000") + _ = r.Run(":" + cfg.port) } diff --git a/docker-compose.yaml b/docker-compose.yaml index 05c34a9..ed3b568 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,6 +10,7 @@ services: - VK_GROUP_ID - VK_CONFIRMATION_STRING - TG_TOKEN + - PORT=8000 ports: - "127.0.0.1:8888:8000"