Skip to content

Docker #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]

ENTRYPOINT java $JAVA_OPTS -jar /opt/helloword/springboot-helloworld-0.0.1.jar
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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" .