最近在帮公司在客户的PaaS平台部署程序,本来想吐槽一波中国移动的磐舟(CI)和磐基(CD)平台基础设施没做好,流程没打通来着。。。
想来吐槽也没啥用,人家没给你基础镜像,但Harbor有外网也还好,自己打吧。。
所以这篇就简单记录下用AlpineLinux构建一个Tomcat的Docker镜像,无论是基于X86_64还是aarch64,只要基于Alpine镜像的都支持。
docker pull hellxz/alpine-tomcat:openjdk8-tomcat-8.5.78
FROM alpine:3.14.3
COPY glibc/ .
ADD apache-tomcat-8.5.78.tar.gz /usr/local
RUN \
#install glibc6
mv sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub; \
apk add *.apk; \
rm -rf *.apk; \
#install jdk and useful utils
echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories; \
echo "http://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories; \
apk upgrade; \
apk add --no-cache ca-certificates unzip curl bash bash-completion wget vim net-tools tzdata openjdk8; \
rm -rf /tmp/* /var/cache/apk/*; \
#make soft link to /usr/local/tomcat
ln -s /usr/local/apache-tomcat-8.5.78 /usr/local/tomcat; \
#delete unused folders
rm -rf /usr/local/tomcat/webapps/*
ENV CATALINA_HOME=/usr/local/tomcat \
LANG=C.UTF-8 \
TZ=Asia/Shanghai
ENV PATH=$CATALINA_HOME/bin:$PATH
WORKDIR /usr/local/tomcat
EXPOSE 8080
CMD ["catalina.sh", "run"]
git clone https://github.com/hellxz/AlpineLinux-Tomcat-Image.git
cd AlpineLinux-Tomcat-Image
docker build -t hellxz/alpine-tomcat:openjdk8-tomcat-8.5.78 .
复制war包至镜像目录/usr/local/tomcat/webapps中即可,直接引用官方仓库中的镜像,示例如下:
Dockerfile
FROM hellxz/alpine-tomcat:openjdk8-tomcat-8.5.78
COPY app.war /usr/local/tomcat/webapps/
Build
docker build -t tomcat-deploy-test .
Run
docker run -d -p 8080:8080 tomcat-deploy-test
今天就分享这些,我是Hellxz我们下次再见。
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://www.cnblogs.com/hellxz/p/build-alpine-openjdk8-tomcat8-docker-image.html
内容来源于网络,如有侵权,请联系作者删除!