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 (
"fmt"
"os"
"runtime"
"strconv"
"strings"
@ -61,7 +62,12 @@ func GetBeegoConfDataSourceName() string {
runningInDocker := os.Getenv("RUNNING_IN_DOCKER")
if runningInDocker == "true" {
dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "host.docker.internal")
// 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")
}
}
return dataSourceName

View File

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