Add port environment variable

This commit is contained in:
Artyom Belousov 2023-05-28 00:04:30 +03:00
parent cd326bcfac
commit 77768ff431
2 changed files with 8 additions and 1 deletions

View file

@ -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)
}

View file

@ -10,6 +10,7 @@ services:
- VK_GROUP_ID
- VK_CONFIRMATION_STRING
- TG_TOKEN
- PORT=8000
ports:
- "127.0.0.1:8888:8000"