Fix cannot support old Docker version bug, revert PR: https://github.com/casdoor/casdoor/pull/606

This commit is contained in:
Gucheng Wang
2022-06-15 01:20:00 +08:00
parent 1b5a8f8e57
commit 2020955270
2 changed files with 7 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ package conf
import ( import (
"fmt" "fmt"
"os" "os"
"runtime"
"strconv" "strconv"
"strings" "strings"
@@ -61,8 +62,13 @@ func GetBeegoConfDataSourceName() string {
runningInDocker := os.Getenv("RUNNING_IN_DOCKER") runningInDocker := os.Getenv("RUNNING_IN_DOCKER")
if runningInDocker == "true" { if runningInDocker == "true" {
// https://stackoverflow.com/questions/48546124/what-is-linux-equivalent-of-host-docker-internal
if runtime.GOOS == "linux" {
dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "172.17.0.1")
} else {
dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "host.docker.internal") dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "host.docker.internal")
} }
}
return dataSourceName return dataSourceName
} }

View File

@@ -12,8 +12,6 @@ services:
- db - db
environment: environment:
RUNNING_IN_DOCKER: "true" RUNNING_IN_DOCKER: "true"
extra_hosts:
- "host.docker.internal:host-gateway"
volumes: volumes:
- ./conf:/conf/ - ./conf:/conf/
db: db: