container/构建SpringBoot2镜像.md

19 lines
568 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```
FROM docker.1ms.run/library/mvn-java-8:latest
ENV PROJECT_ACTIVE=根据实际情况激活 application-xxx.yaml 配置文件比如prod
WORKDIR /app
EXPOSE springboot 内嵌的 servlet 容器端口号
# 配置容器启动命令
RUN << 'EOF' cat > /entrypoint.sh
#!/bin/bash
set -e
cd /app && rm -rf 源码目录
git clone "http://用户名:密码@远程仓库地址.git"
cd /app/源码目录 && mvn clean package
exec java -jar target/jar包名称.jar --spring.profiles.active=$PROJECT_ACTIVE
EOF
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
```