我按照本教程构建了docker镜像https://spring.io/guides/gs/spring-boot-docker/#initial
在本教程中,使用以下命令构建Docker映像:
./mvnw install dockerfile:build
我成功地在我的centos机器上建立了映像。 现在,我正在尝试使用Gitlab Ci创建一个管道
我有这个.gitlab.yml文件conf:
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
USER_GITLAB: myname
APP_NAME: mpayment
REPO: repo-mpayment
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
stages:
- build
- docker
maven-build:
image: maven:3-jdk-8
stage: build
script:
- "./mvnw install"
- "ls target"
artifacts:
paths:
- target/*.jar
docker-build:
stage: docker
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
maven构建成功,并生成了这些文件夹和文件
classes generated-sources maven-status surefire-reports
dependency generated-test-sources mpayment-0.0.1-SNAPSHOT.jar test-classes
dependency-maven-plugin-markers maven-archiver mpayment-0.0.1-SNAPSHOT.jar.original
和
ls target/dependency/
BOOT-INF
META-INF
org
但是docker build返回错误
Step 4/7 : COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY failed: stat /var/lib/docker/tmp/docker-builder082248913/target/dependency/BOOT-INF/lib: no such file or directory
似乎docker build正在另一个上下文中运行并且找不到依赖项文件夹。 我该怎么做才能保持创建的上下文和文件相同?
预先感谢