Я попытался запустить микросервис Spring Cloud на jdk alpine образе docker, но во время запуска двух контейнеров я получил следующее сообщение:
licensingservice_1 | BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.
licensingservice_1 |
licensingservice_1 | Usage: basename FILE [SUFFIX]
licensingservice_1 |
licensingservice_1 | Strip directory path and .SUFFIX from FILE
licensingservice_1 | usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-O length]
licensingservice_1 | [-P proxy_username] [-p source_port] [-q seconds] [-s source]
licensingservice_1 | [-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
licensingservice_1 | [-x proxy_address[:port]] [destination] [port]
Вот файл docker и файл run.sh, которыеиспользуется для создания образа.
DockerFile
FROM openjdk:8-jdk-alpine
RUN apk update && apk upgrade && apk add netcat-openbsd
RUN mkdir -p /usr/local/licensingservice
ADD @project.build.finalName@.jar /usr/local/licensingservice/
ADD run.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh
run.sh
#!/bin/sh
getPort() {
echo $1 | cut -d : -f 3 | xargs basename
}
echo "********************************************************"
echo "Waiting for the eureka server to start on port $(getPort $EUREKASERVER_PORT)"
echo "********************************************************"
while ! `nc -z eurekaserver $(getPort $EUREKASERVER_PORT)`; do sleep 3; done
echo "******* Eureka Server has started"
echo "********************************************************"
echo "Waiting for the configuration server to start on port $(getPort $CONFIGSERVER_PORT)"
echo "********************************************************"
while ! `nc -z configserver $(getPort $CONFIGSERVER_PORT)`; do sleep 3; done
echo "******* Configuration Server has started"
echo "********************************************************"
echo "Waiting for the kafka server to start on port $(getPort $KAFKASERVER_PORT)"
echo "********************************************************"
while ! `nc -z kafkaserver $(getPort $KAFKASERVER_PORT)`; do sleep 10; done
echo "******* Kafka Server has started"
echo "********************************************************"
echo "Starting License Server with Configuration Service via Eureka : $EUREKASERVER_URI:$SERVER_PORT"
echo "Using Kafka Server: $KAFKASERVER_URI"
echo "Using ZK Server: $ZKSERVER_URI"
echo "USing Profile: $PROFILE"
echo "********************************************************"
java -Djava.security.egd=file:/dev/./urandom -Dserver.port=$SERVER_PORT \
-Deureka.client.serviceUrl.defaultZone=$EUREKASERVER_URI \
-Dspring.cloud.config.uri=$CONFIGSERVER_URI \
-Dspring.cloud.stream.kafka.binder.zkNodes=$KAFKASERVER_URI \
-Dspring.cloud.stream.kafka.binder.brokers=$ZKSERVER_URI \
-Dsecurity.oauth2.resource.userInfoUri=$AUTHSERVER_URI \
-Dspring.profiles.active=$PROFILE -jar /usr/local/licensingservice/@project.build.finalName@.jar
Я построилобраз с командой mvn clean package docker:build
с плагином spotify docker 1.2.0