Im trying to start jhipster-registry with prod-profile (from my local machine, to test prod configuration among other things) with the following docker-compose file
version: '3.8'
services:
jhipster-registry:
image: jhipster/jhipster-registry:v6.8.0
volumes:
- ./central-server-config:/central-config
# When run with the "dev" Spring profile, the JHipster Registry will
# read the config from the local filesystem (central-server-config directory)
# When run with the "prod" Spring profile, it will read the configuration from a Git repository
# See https://www.jhipster.tech/jhipster-registry/#spring-cloud-config
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,api-docs
- SPRING_SECURITY_USER_PASSWORD=changeme
- JHIPSTER_REGISTRY_PASSWORD=changeme
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=git@github.com:<user>/<git-repo-config>.git
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_IGNORE_LOCAL_SSH_SETTINGS=true
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_HOST_KEY=github.com
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_HOST_KEY_ALGORITHM=ssh-rsa
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_PRIVATE_KEY=|
-----BEGIN RSA PRIVATE KEY-----
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
DDVHEEYGbSQ6hIGSh0I7BQun0aLRZojfE3gqHQIDAQABAoIBAQCZmGrk8BK6tXCd
-----END RSA PRIVATE KEY-----
# - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_PATHS=central-config
# If you want to expose these ports outside your dev PC,
# remove the "127.0.0.1:" prefix
ports:
- 127.0.0.1:8761:8761
According to the docs, it only support ssh-rsa format so I create a new ssh key with rsa and PEM format (ssh-keygen -m PEM -t rsa -b 4096 -C "<user@domain.com>"
) and no password and upload (the public key) to my git account.
I tested that I can push to my < config-git-repo >.git using this private rsa key. I have checked that the generated keys are in a PEM format (starts with -----BEGIN RSA PRIVATE KEY-----), according to the docs.
But the registry fails to start (docker-compose -f registry.yml up) with exception
jhipster-registry_1 | Caused by: org.springframework.boot.context.properties.bind.validation.BindValidationException: Binding validation errors on spring.cloud.config.server.git
jhipster-registry_1 | - Error in object 'spring.cloud.config.server.git': codes [PrivateKeyIsValid.spring.cloud.config.server.git,PrivateKeyIsValid]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.config.server.git.,]; arguments []; default message []]; default message [Property 'spring.cloud.config.server.git.privateKey' is not a valid private key]
According to the docs:
Warning: When working with SSH keys, the expected ssh private-key must begin with -----BEGIN RSA PRIVATE KEY-----. If the key starts with -----BEGIN OPENSSH PRIVATE KEY----- then the RSA key will not load when spring-cloud-config server is started. The error looks like:
- Error in object 'spring.cloud.config.server.git': codes [PrivateKeyIsValid.spring.cloud.config.server.git,PrivateKeyIsValid]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.config.server.git.,]; arguments []; default message []]; default message [Property 'spring.cloud.config.server.git.privateKey' is not a valid private key]
Just as my error but the key is in correct format. I can't figure out what's wrong, any ideas? I copy the private key with the following command in macosx pbcopy < ~/.ssh/id_rsa
to the docker-compose file, so it should be the correct file content and also the first line says -----BEGIN RSA PRIVATE KEY-----
Furthermore I checked that the private key fingerprint (ssh-keygen -l -f id_rsa.pub
) is the same as in my git account, which it was.
I also tried different indentations but no luck.