1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Merge pull request #35 from YC/master

feat: add base_path environment variable
This commit is contained in:
Ferdinand Mütsch 2020-07-14 20:14:23 +02:00 committed by GitHub
commit f86eb7668d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -9,7 +9,7 @@ RUN cd /src && go build -o wakapi
# When running the application using `docker run`, you can pass environment variables # When running the application using `docker run`, you can pass environment variables
# to override config values from .env using `-e` syntax. # to override config values from .env using `-e` syntax.
# Available options are: # Available options are:
# WAKAPI_DB_TYPE # WAKAPI_DB_TYPE
# WAKAPI_DB_USER # WAKAPI_DB_USER
# WAKAPI_DB_PASSWORD # WAKAPI_DB_PASSWORD
@ -17,8 +17,7 @@ RUN cd /src && go build -o wakapi
# WAKAPI_DB_PORT # WAKAPI_DB_PORT
# WAKAPI_DB_NAME # WAKAPI_DB_NAME
# WAKAPI_PASSWORD_SALT # WAKAPI_PASSWORD_SALT
# WAKAPI_DEFAULT_USER_NAME # WAKAPI_BASE_PATH
# WAKAPI_DEFAULT_USER_PASSWORD
FROM debian FROM debian
WORKDIR /app WORKDIR /app
@ -30,8 +29,6 @@ ENV WAKAPI_DB_PASSWORD ''
ENV WAKAPI_DB_HOST '' ENV WAKAPI_DB_HOST ''
ENV WAKAPI_DB_NAME=/data/wakapi.db ENV WAKAPI_DB_NAME=/data/wakapi.db
ENV WAKAPI_PASSWORD_SALT '' ENV WAKAPI_PASSWORD_SALT ''
ENV WAKAPI_DEFAULT_USER_NAME admin
ENV WAKAPI_DEFAULT_USER_PASSWORD admin
COPY --from=build-env /src/wakapi /app/ COPY --from=build-env /src/wakapi /app/
COPY --from=build-env /src/config.ini /app/ COPY --from=build-env /src/config.ini /app/

View File

@ -161,7 +161,11 @@ func readConfig() *Config {
port = cfg.Section("server").Key("port").MustInt() port = cfg.Section("server").Key("port").MustInt()
} }
basePathEnv, basePathEnvExists := os.LookupEnv("WAKAPI_BASE_PATH")
basePath := cfg.Section("server").Key("base_path").MustString("/") basePath := cfg.Section("server").Key("base_path").MustString("/")
if basePathEnvExists {
basePath = basePathEnv
}
if strings.HasSuffix(basePath, "/") { if strings.HasSuffix(basePath, "/") {
basePath = basePath[:len(basePath)-1] basePath = basePath[:len(basePath)-1]
} }