gpt4 book ai didi

基于AlpineLinux构建Tomcat的Docker镜像

转载 作者:知者 更新时间:2024-03-13 01:32:10 24 4
gpt4 key购买 nike

Reason

最近在帮公司在客户的PaaS平台部署程序,本来想吐槽一波中国移动的磐舟(CI)和磐基(CD)平台基础设施没做好,流程没打通来着。。。

想来吐槽也没啥用,人家没给你基础镜像,但Harbor有外网也还好,自己打吧。。

所以这篇就简单记录下用AlpineLinux构建一个Tomcat的Docker镜像,无论是基于X86_64还是aarch64,只要基于Alpine镜像的都支持。

Dockerfile

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"]

Build

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 .

Use

复制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我们下次再见。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com