Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: env var config #2143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The following options are currently available to install the CLI locally.

Here are the server configuration options.

Command line flags:
### Command line flags

```console
$ yopass-server -h
Expand All @@ -103,6 +103,22 @@ $ yopass-server -h

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

### Environment variables

```console
YOPASS_ADDRESS # listen address (default 0.0.0.0)
YOPASS_DATABASE # database backend ('memcached' or 'redis') (default "memcached")
YOPASS_MAX_LENGTH # max length of encrypted secret (default 10000)
YOPASS_MEMCACHED # Memcached address (default "localhost:11211")
YOPASS_METRICS_PORT # metrics server listen port (default -1)
YOPASS_PORT # listen port (default 1337)
YOPASS_REDIS # Redis URL (default "redis://localhost:6379/0")
YOPASS_TLS_CERT # path to TLS certificate
YOPASS_TLS_KEY # path to TLS key
```

see [docker compose example](deploy/docker-compose/env-config/docker-compose.yml)

### Docker Compose

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:
Expand Down Expand Up @@ -183,4 +199,5 @@ Here's a list of available translations:
- [French](https://github.com/NicolasStr/yopass-french)
- [Spanish](https://github.com/nbensa/yopass-spanish)
- [Polish](https://github.com/mdurajewski/yopass-polish)
- [Dutch](https://github.com/KevinRosendaal/yopass-dutch)
- [Dutch](https://github.com/KevinRosendaal/yopass-dutch)
- [Russian](https://github.com/karpechenkovkonstantin/yopass-russian)
1 change: 1 addition & 0 deletions cmd/yopass-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func init() {
pflag.Bool("force-onetime-secrets", false, "reject non onetime secrets from being created")
pflag.CommandLine.AddGoFlag(&flag.Flag{Name: "log-level", Usage: "Log level", Value: &logLevel})

viper.SetEnvPrefix("yopass")
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
_ = viper.BindPFlags(pflag.CommandLine)
Expand Down
34 changes: 34 additions & 0 deletions deploy/docker-compose/env-config/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3.0"

services:
memcached:
image: memcached
restart: always
expose:
- "11211"

yopass:
image: jhaals/yopass
restart: always
ports:
- "127.0.0.1:80:80"
- "127.0.0.1:9090:9090"
environment:
# listen address (default 0.0.0.0)
# - YOPASS_ADDRESS
# listen port (default 1337)
- YOPASS_PORT=80
# metrics server listen port (default -1)
- YOPASS_METRICS_PORT=9090
# max length of encrypted secret (default 10000)
- YOPASS_MAX_LENGTH=100000
# database backend ('memcached' or 'redis') (default "memcached")
- YOPASS_DATABASE=memcached
# Memcached address (default "localhost:11211")
- YOPASS_MEMCACHED=localhost:11211
# Redis URL (default "redis://localhost:6379/0")
# - YOPASS_REDIS=redis://localhost:6379/0
# path to TLS certificate
# - YOPASS_TLS_CERT
# path to TLS key
# - YOPASS_TLS_KEY