diff --git a/Dockerfile b/Dockerfile index 78db5e1..051a823 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,15 @@ FROM registry.cn-shanghai.aliyuncs.com/mydlq/openjdk:8u201-jdk-alpine3.9 -VOLUME /tmp -ADD target/*.jar app.jar -RUN sh -c 'touch /app.jar' + +EXPOSE 8080 + +RUN mkdir -p /opt/helloword + +COPY target/springboot-helloworld-0.0.1.jar /opt/helloword/ + +RUN chmod 777 /opt/helloword/* -R + +WORKDIR /opt/helloword/ + ENV JAVA_OPTS="-Xmx512M -Xms256M -Xss256k -Duser.timezone=Asia/Shanghai" -ENV APP_OPTS="" -ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar $APP_OPTS" ] \ No newline at end of file + +ENTRYPOINT java $JAVA_OPTS -jar /opt/helloword/springboot-helloworld-0.0.1.jar diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..d31bdff --- /dev/null +++ b/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin + +export WORKDIR=$( cd ` dirname $0 ` && pwd ) +cd "$WORKDIR" || exit 1 + +mvn -version +mvn -DskipTests=true package + +#Exec docker build +set -o errexit #只要出错就退出 +set -o nounset #不允许引用不存在的变量 +set -o pipefail #各管道内不允许出错 + +execute() { printf "【INFO】command: %s\n" "$*"; eval "$*";} +image_tag="" +execute "docker build --no-cache --pull -f Dockerfile" .