From 3081eae60f62f18a36ced91e57276d39877ce904 Mon Sep 17 00:00:00 2001 From: Arjan H Date: Sat, 6 Sep 2025 13:34:52 +0200 Subject: [PATCH] Also allow names in standalone DB config (#198) --- README_standalone.md | 52 ++++++++++++++++++++++++++++++++++++++++++++ gui/main.go | 7 +++--- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/README_standalone.md b/README_standalone.md index cc34f51..80258a0 100644 --- a/README_standalone.md +++ b/README_standalone.md @@ -43,6 +43,58 @@ or docker run -it --rm -v /home/username/acme:/opt/acme ghcr.io/hakwerk/labca-standalone labca-gui -config /opt/acme/stepca.json ``` +### Docker Compose + +Here is a sample `docker-compose.yml` file for using both StepCA and the LabCA gui: +``` +services: + smallstep: + image: smallstep/step-ca + restart: unless-stopped + ports: + - 9000:9000 + volumes: + - /mystorage/stepca:/home/step + environment: + DOCKER_STEPCA_INIT_NAME: StepCA + DOCKER_STEPCA_INIT_DNS_NAMES: mydomain + DOCKER_STEPCA_INIT_PROVISIONER_NAME: admin + depends_on: + - db + web: + image: ghcr.io/hakwerk/labca-standalone + ports: + - 3000:3000 + volumes: + - /mystorage/labca/config/stepca_config.json:/usr/data/config.json + depends_on: + - db + db: + user: 3020:3020 + image: mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: stepca + MYSQL_USER: stepca + MYSQL_PASSWORD: userpassword + MYSQL_TCP_PORT: 3306 + volumes: + - /mystorage/labca/db:/var/lib/mysql + healthcheck: + test: + - CMD + - mysqladmin + - ping + - -h + - localhost + - -uroot + - -prootpassword + interval: 10s + timeout: 5s + retries: 5 +networks: {} +``` ## systemd service diff --git a/gui/main.go b/gui/main.go index 20c44ac..abf6d70 100644 --- a/gui/main.go +++ b/gui/main.go @@ -2460,11 +2460,10 @@ func writeStandaloneConfig(cfg *StandaloneConfig) { conn += ":" + cfg.MySQLPasswd } conn += "@" - _, err := strconv.Atoi(string(strings.TrimSpace(cfg.MySQLServer)[0])) - if err == nil { - conn += "tcp(" + cfg.MySQLServer + ":" + cfg.MySQLPort + ")" - } else { + if strings.HasPrefix(cfg.MySQLServer, "tcp(") { conn += cfg.MySQLServer + ":" + cfg.MySQLPort + } else { + conn += "tcp(" + cfg.MySQLServer + ":" + cfg.MySQLPort + ")" } conn += "/" + cfg.MySQLDBName