Skip to content

Commit 5eeb070

Browse files
authored
Merge pull request #2143 from 24367dfa/feat/env-var-config
Feature: env var config
2 parents 976d7b2 + 4d949e1 commit 5eeb070

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The following options are currently available to install the CLI locally.
8282

8383
Here are the server configuration options.
8484

85-
Command line flags:
85+
### Command line flags
8686

8787
```console
8888
$ yopass-server -h
@@ -99,6 +99,22 @@ $ yopass-server -h
9999

100100
Encrypted secrets can be stored either in Memcached or Redis by changing the `--database` flag.
101101

102+
### Environment variables
103+
104+
```console
105+
YOPASS_ADDRESS # listen address (default 0.0.0.0)
106+
YOPASS_DATABASE # database backend ('memcached' or 'redis') (default "memcached")
107+
YOPASS_MAX_LENGTH # max length of encrypted secret (default 10000)
108+
YOPASS_MEMCACHED # Memcached address (default "localhost:11211")
109+
YOPASS_METRICS_PORT # metrics server listen port (default -1)
110+
YOPASS_PORT # listen port (default 1337)
111+
YOPASS_REDIS # Redis URL (default "redis://localhost:6379/0")
112+
YOPASS_TLS_CERT # path to TLS certificate
113+
YOPASS_TLS_KEY # path to TLS key
114+
```
115+
116+
see [docker compose example](deploy/docker-compose/env-config/docker-compose.yml)
117+
102118
### Docker Compose
103119

104120
Use the Docker Compose file `deploy/with-nginx-and-letsencrypt/docker-compose.yml` to set up a yopass instance with TLS transport encryption and certificate auto renewal using [Let's Encrypt](https://letsencrypt.org/). First point your domain to the host you want to run yopass on. Then replace the placeholder values for `VIRTUAL_HOST`, `LETSENCRYPT_HOST` and `LETSENCRYPT_EMAIL` in `deploy/with-nginx-and-letsencrypt/docker-compose.yml` with your values. Afterwards change the directory to `deploy/with-nginx-and-letsencrypt` and start the containers with:

cmd/yopass-server/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func init() {
3939
pflag.Bool("force-onetime-secrets", false, "reject non onetime secrets from being created")
4040
pflag.CommandLine.AddGoFlag(&flag.Flag{Name: "log-level", Usage: "Log level", Value: &logLevel})
4141

42+
viper.SetEnvPrefix("yopass")
4243
viper.AutomaticEnv()
4344
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
4445
_ = viper.BindPFlags(pflag.CommandLine)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "3.0"
2+
3+
services:
4+
memcached:
5+
image: memcached
6+
restart: always
7+
expose:
8+
- "11211"
9+
10+
yopass:
11+
image: jhaals/yopass
12+
restart: always
13+
ports:
14+
- "127.0.0.1:80:80"
15+
- "127.0.0.1:9090:9090"
16+
environment:
17+
# listen address (default 0.0.0.0)
18+
# - YOPASS_ADDRESS
19+
# listen port (default 1337)
20+
- YOPASS_PORT=80
21+
# metrics server listen port (default -1)
22+
- YOPASS_METRICS_PORT=9090
23+
# max length of encrypted secret (default 10000)
24+
- YOPASS_MAX_LENGTH=100000
25+
# database backend ('memcached' or 'redis') (default "memcached")
26+
- YOPASS_DATABASE=memcached
27+
# Memcached address (default "localhost:11211")
28+
- YOPASS_MEMCACHED=localhost:11211
29+
# Redis URL (default "redis://localhost:6379/0")
30+
# - YOPASS_REDIS=redis://localhost:6379/0
31+
# path to TLS certificate
32+
# - YOPASS_TLS_CERT
33+
# path to TLS key
34+
# - YOPASS_TLS_KEY

0 commit comments

Comments
 (0)