Skip to content

Commit bb017c5

Browse files
committed
feat: remove env prefix for docker
1 parent c51dc45 commit bb017c5

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ VOLUME /opt/alist/data/
1111
WORKDIR /opt/alist/
1212
COPY --from=builder /app/bin/alist ./
1313
EXPOSE 5244
14-
CMD [ "./alist" ]
14+
CMD [ "./alist -docker" ]

bootstrap/conf.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ func InitConf() {
5454
}
5555

5656
func confFromEnv() {
57-
if err := env.Parse(conf.Conf); err != nil {
57+
prefix := "ALIST_"
58+
if conf.Docker {
59+
prefix = ""
60+
}
61+
if err := env.Parse(conf.Conf, env.Options{
62+
Prefix: prefix,
63+
}); err != nil {
5864
log.Fatalf("load config from env error: %s", err.Error())
5965
}
6066
}

bootstrap/log.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func init() {
3030
flag.BoolVar(&conf.Debug, "debug", false, "start with debug mode")
3131
flag.BoolVar(&conf.Version, "version", false, "print version info")
3232
flag.BoolVar(&conf.Password, "password", false, "print current password")
33+
flag.BoolVar(&conf.Docker, "docker", false, "is using docker")
3334
flag.Parse()
3435
InitLog()
3536
}

conf/config.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
package conf
22

33
type Database struct {
4-
Type string `json:"type" env:"A_LIST_DB_TYPE"`
5-
User string `json:"user" env:"A_LIST_DB_USER"`
6-
Password string `json:"password" env:"A_LIST_DB_PASS"`
7-
Host string `json:"host" env:"A_LIST_DB_HOST"`
8-
Port int `json:"port" env:"A_LIST_DB_PORT"`
9-
Name string `json:"name" env:"A_LIST_DB_NAME"`
10-
TablePrefix string `json:"table_prefix" env:"A_LIST_DB_TABLE_PREFIX"`
11-
DBFile string `json:"db_file" env:"A_LIST_DB_FILE"`
12-
SslMode string `json:"ssl_mode" env:"A_LIST_SLL_MODE"`
4+
Type string `json:"type" env:"DB_TYPE"`
5+
Host string `json:"host" env:"DB_HOST"`
6+
Port int `json:"port" env:"DB_PORT"`
7+
User string `json:"user" env:"DB_USER"`
8+
Password string `json:"password" env:"DB_PASS"`
9+
Name string `json:"name" env:"DB_NAME"`
10+
DBFile string `json:"db_file" env:"DB_FILE"`
11+
TablePrefix string `json:"table_prefix" env:"DB_TABLE_PREFIX"`
12+
SslMode string `json:"ssl_mode" env:"DB_SLL_MODE"`
1313
}
1414

1515
type Scheme struct {
16-
Https bool `json:"https" env:"A_LIST_HTTPS"`
17-
CertFile string `json:"cert_file" env:"A_LIST_CERT"`
18-
KeyFile string `json:"key_file" env:"A_LIST_KEY"`
16+
Https bool `json:"https" env:"HTTPS"`
17+
CertFile string `json:"cert_file" env:"CERT_FILE"`
18+
KeyFile string `json:"key_file" env:"KEY_FILE"`
1919
}
2020

2121
type CacheConfig struct {
22-
Expiration int64 `json:"expiration" env:"A_LIST_EXPIRATION"`
23-
CleanupInterval int64 `json:"cleanup_interval" env:"A_LIST_CLEANUP_INTERVAL"`
22+
Expiration int64 `json:"expiration" env:"CACHE_EXPIRATION"`
23+
CleanupInterval int64 `json:"cleanup_interval" env:"CLEANUP_INTERVAL"`
2424
}
2525

2626
type Config struct {
2727
Force bool `json:"force"`
28-
Address string `json:"address" env:"A_LIST_ADDR"`
29-
Port int `json:"port" env:"A_LIST_PORT"`
30-
Assets string `json:"assets" env:"A_LIST_ASSETS"`
28+
Address string `json:"address" env:"ADDR"`
29+
Port int `json:"port" env:"PORT"`
30+
Assets string `json:"assets" env:"ASSETS"`
3131
Database Database `json:"database"`
3232
Scheme Scheme `json:"scheme"`
3333
Cache CacheConfig `json:"cache"`
34-
TempDir string `json:"temp_dir" env:"A_LIST_TEMP_DIR"`
34+
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
3535
}
3636

3737
func DefaultConfig() *Config {

conf/var.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
Debug bool
2525
Version bool
2626
Password bool
27+
Docker bool
2728

2829
DB *gorm.DB
2930
Cache *cache.Cache

0 commit comments

Comments
 (0)