【发布时间】:2019-03-01 04:49:40
【问题描述】:
我目前正在通过 Dockerfile 运行一个 gradle 项目。我要求在具有 Internet 连接的开发服务器上进行构建,并将 docker 映像部署在没有 Internet 连接的生产服务器上。为此,我试图在 gradle-clean 期间获取所有依赖项。但是当我运行 docker 镜像时,它再次尝试从存储库中下载所有依赖的 jar。如何使它指向仅在 gradle-clean 期间创建的缓存。 我是 Docker 框架的新手,感谢任何帮助。 谢谢。
Dockerfile如下:
FROM openjdk:8
RUN mkdir -p /home/pma
WORKDIR /home/pma
VOLUME ["/home/pma"]
VOLUME ["/root/.gradle/caches/"]
#Setup gradle in the docker image and configure path variables
RUN \
cd /usr/local && \
curl -L https://services.gradle.org/distributions/gradle-4.2.1-bin.zip -o gradle-4.2.1-bin.zip && \
unzip gradle-4.2.1-bin.zip && \
rm gradle-4.2.1-bin.zip
ENV GRADLE_HOME=/usr/local/gradle-4.2.1
ENV PATH=$GRADLE_HOME/bin:$PATH
#Add the base code to the docker image
ADD . /home/pma/
#Here I am trying to download all dependencies which will be pushed to /root/.gradle/caches/
RUN ["gradle","--stacktrace","clean"]
#to be executed during the container creation phase
CMD ["gradle","--stacktrace","bootRun"]
【问题讨论】:
标签: java docker spring-boot gradle dockerfile