1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-21 21:33:18 +01:00

feat: reads certs locally if available (#3196)

This commit is contained in:
Amir Raminfar
2024-08-13 11:48:56 -07:00
committed by GitHub
parent 9467e3d7d5
commit 7f735d26db
3 changed files with 33 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
services:
agent:
image: amir20/dozzle:pr-3196
command: agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock
secrets:
- source: cert
target: /dozzle_cert.pem
- source: key
target: /dozzle_key.pem
ports:
- 7070:7070
secrets:
cert:
file: ./cert.pem
key:
file: ./key.pem

View File

@@ -1,6 +1,6 @@
services: services:
my-dozzle-service: dozzle-service:
image: amir20/dozzle:local-test image: amir20/dozzle:latest
environment: environment:
- DOZZLE_LEVEL=debug - DOZZLE_LEVEL=debug
- DOZZLE_MODE=swarm - DOZZLE_MODE=swarm

View File

@@ -3,9 +3,22 @@ package cli
import ( import (
"crypto/tls" "crypto/tls"
"embed" "embed"
"os"
log "github.com/sirupsen/logrus"
) )
func ReadCertificates(certs embed.FS) (tls.Certificate, error) { func ReadCertificates(certs embed.FS) (tls.Certificate, error) {
if pair, err := tls.LoadX509KeyPair("dozzle_cert.pem", "dozzle_key.pem"); err == nil {
log.Infof("Found dozzle certificate and key at ./dozzle_cert.pem and ./dozzle_key.pem")
return pair, nil
} else {
if !os.IsNotExist(err) {
log.Errorf("Failed to load dozzle certificate and key: %v", err)
log.Warnf("Falling back to shared certificate and key")
}
}
cert, err := certs.ReadFile("shared_cert.pem") cert, err := certs.ReadFile("shared_cert.pem")
if err != nil { if err != nil {
return tls.Certificate{}, err return tls.Certificate{}, err