-
Notifications
You must be signed in to change notification settings - Fork 22
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
read API_KEY from file #48
Comments
Whilst it would be great to get this officially supported here is a head start for people not wanting to wait: Creating a go appWe will replace the start up file to read the value from the file then call the other go app.
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
)
func main() {
keyBytes, err := ioutil.ReadFile("/run/secrets/traefik.bouncer")
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to read API key: %v\n", err)
os.Exit(1)
}
key := strings.TrimSpace(string(keyBytes))
os.Setenv("CROWDSEC_BOUNCER_API_KEY", string(key))
cmd := exec.Command("/app")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to run app: %v\n", err)
os.Exit(1)
}
}
Using the go app for startup
traefik-bouncer:
image: fbonalair/traefik-crowdsec-bouncer
container_name: traefik-bouncer
volumes:
- ./secrets_startup/traefik-bouncer:/traefik-bouncer
command: ["/traefik-bouncer"]
restart: always
networks:
- traefik_default
environment:
GIN_MODE: release
CROWDSEC_AGENT_HOST: crowdsec:8080
CROWDSEC_BOUNCER_LOG_LEVEL: 2
secrets:
- traefik.bouncer
Extra NotesThere is already a PR so hopefully this will not be needed for long. (#29) |
Thank you - works fine for me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use the secrets mechanism of docker und would like to read environment-variables from a file. CROWDSEC_BOUNCER_API_KEY_FILE e.g.
The text was updated successfully, but these errors were encountered: