jianwei-dai

1、本地windows安装docker环境---不赘述,网上搜下

2、编写DockerFile文件(后台)

# 指定基础镜像,这是分阶段构建的前期阶段
FROM openjdk:8u212-jdk-stretch as builder
# 执行工作目录
WORKDIR /usr/local/report
# 将编译构建得到的jar文件复制到镜像空间中
COPY scf-report.jar  report.jar
COPY ZSMART_HOME ZSMART_HOME
COPY startup.sh startup.sh
# 通过工具spring-boot-jarmode-layertools从platform.jar中提取拆分后的构建结果
# RUN java -Djarmode=layertools -jar platform.jar extract
# chmod +x
# ENTRYPOINT ["java", " -DZSMART_HOME=ZSMART_HOME ", "-jar", "report.jar"]
# RUN chmod +x startup.sh
RUN chmod 777 startup.sh
CMD ["bash", "-c", "./startup.sh start report.jar"]
# CMD bash -c ./startup.sh start platform.jar && bash -ce tail -f /dev/null
# ENTRYPOINT  tailf /usr/local/platform/log/stdout.out
# ENTRYPOINT ["java","-jar","platform.jar"]
# RUN chmod +x /usr/local/platform/startup.sh
# RUN bash startup.sh
# ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
# 正式构建镜像
# FROM openjdk:8u212-jdk-stretch
# WORKDIR logistics
# 前一阶段从jar中提取除了多个文件,这里分别执行COPY命令复制到镜像空间中,每次COPY都是一个layer
# COPY --from=builder logistics/dependencies/ ./
# COPY --from=builder logistics/spring-boot-loader/ ./
# COPY --from=builder logistics/snapshot-dependencies/ ./
# COPY --from=builder logistics/logistics/ ./
# ENTRYPOINT ["chmod +x /startup.sh"]
# ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]


3、构建镜像

docker build -t 10.18.36.160:8082/pandalink-tst/platform:v$time2 .

4、打镜像tar包

docker save -o platform.tar 10.18.36.160:8082/pandalink-tst/platform:v$time2

5、推送镜像包到镜像仓库

docker push

 

 

 

前台DockerFile

FROM centos
COPY nginx-1.18.0.tar.gz nginx-1.18.0.tar.gz  
RUN mkdir /usr/local/nginx
RUN mkdir /usr/local/nginx/conf/
RUN mkdir /usr/local/nginx/html/
RUN yum -y install gcc make pcre-devel zlib-devel tar zlib
ADD nginx-1.18.0.tar.gz /usr/src/
RUN cd /usr/src/nginx-1.18.0 \
    && ./configure --prefix=/usr/local/nginx --with-stream  && make && make install \
    && ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
COPY nginx.conf /usr/local/nginx/conf/
RUN mkdir /usr/local/nginx/html/cosco/
RUN mkdir /usr/local/nginx/html/portal/
RUN rm -rf /usr/local/nginx/html/cosco/*
COPY cosco  /usr/local/nginx/html/cosco
COPY portal /usr/local/nginx/html/portal
EXPOSE 9088
CMD ["nginx", "-g", "daemon off;"]

分类:

技术点:

相关文章: