I have a spring boot config server which is fetching config files from a remote private GitHub repository using ssh. The service works perfectly when running in local but when I run the service through docker, it runs but unfortunately couldn't fetch the config repo and the reason is I am not able to correctly set up ssh in the docker container.
Here's my application property files -
server:
port: 8888
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: something_url
ignoreLocalSshSettings: false
passphrase: phassphrase
defaultLabel: master
Here's so far what I have tried with my docker file -
FROM openjdk:11
ARG SSH_PRIVATE_KEY
RUN mkdir ~/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_ecdsa
RUN chmod 600 ~/.ssh/id_ecdsa
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN bash -c 'echo -e "Host *\n\tIdentifyFile ~/.ssh/id_ecdsa" >> ~/.ssh/config >> ~/.ssh/config'
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} config-server.jar
ENTRYPOINT ["java", "-jar", "/config-server.jar"]
I am using the following command to create the image -
docker build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_ecdsa)" -t config-server .
The container starts perfectly but as soon as I run the eureka server container it throws the error saying AUTH FAILS