Dockerfile COPY 失败:使用 GitHub CI 时统计没有这样的文件
Dockerfile COPY failed: stat no such file, when using GitHub CI
我正在使用 GitHub 项目的 Gradle 操作,步骤如下:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- run: gradle wrapper
- run: ./gradlew bootJar
- run: ls ./build/libs/
- uses: actions/checkout@v1
- name: Login to docker
run: docker login docker.pkg.github.com -u xxxxxx -p xxxxxx
- uses: actions/checkout@v1
- name: Build the Docker image
run: docker build . -t realtimechat-snapshot-0.$GITHUB_REF
- uses: actions/checkout@v1
- name: Tag the image
run: docker tag realtimechat-snapshot-0.$GITHUB_REF realtimechat-snapshot-0
- uses: actions/checkout@v1
- name: Push the image
run: docker push realtimechat-snapshot-0.$GITHUB_REF
在 Build the Docker image
步骤构建这个 Dockerfile:
FROM alpine:latest
COPY ./build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar
当它尝试复制 jar 文件时出现此错误:
COPY failed: stat
/var/lib/docker/tmp/docker-builder207778036/build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar:
no such file or directory
注意*
在 - run: ls ./build/libs/
的步骤中,它实际上向我展示了 jar 文件:
Run ls ./build/libs/
realtimeChattingSystem-0.0.1-SNAPSHOT.jar
第 2 期
在此
中进行更改后
我遇到了另一个问题
这是步骤:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- run: ./gradlew bootJar
- name: Login to Github regestry
run: docker login docker.pkg.github.com -u xxxxx -p xxxxx
- name: Build the Docker image
run: docker build . -t docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.$GITHUB_REF
- name: Push the image to github
run: docker push docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.$GITHUB_REF
在最后步我得到这个错误:
The push refers to repository
[docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.refs/heads/master]
3aad04996f8f: Preparing
77cae8ab23bf: Preparing
error parsing HTTP 404 response body: invalid character 'p' after top-level value:
"404 page not found\n"
您只需在工作流程开始时使用 actions/checkout
一次。当您在构建后再次使用它时,我认为它可能会将您的本地工作区重置回 GITHUB_SHA
并且您的 jar 文件将在此过程中被删除。
试试这个:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- run: gradle wrapper
- run: ./gradlew bootJar
- run: ls ./build/libs/
- name: Login to docker
run: docker login docker.pkg.github.com -u xxxxxx -p xxxxxx
- name: Build the Docker image
run: docker build . -t realtimechat-snapshot-0.$GITHUB_REF
- name: Tag the image
run: docker tag realtimechat-snapshot-0.$GITHUB_REF realtimechat-snapshot-0
- name: Push the image
run: docker push realtimechat-snapshot-0.$GITHUB_REF
我正在使用 GitHub 项目的 Gradle 操作,步骤如下:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- run: gradle wrapper
- run: ./gradlew bootJar
- run: ls ./build/libs/
- uses: actions/checkout@v1
- name: Login to docker
run: docker login docker.pkg.github.com -u xxxxxx -p xxxxxx
- uses: actions/checkout@v1
- name: Build the Docker image
run: docker build . -t realtimechat-snapshot-0.$GITHUB_REF
- uses: actions/checkout@v1
- name: Tag the image
run: docker tag realtimechat-snapshot-0.$GITHUB_REF realtimechat-snapshot-0
- uses: actions/checkout@v1
- name: Push the image
run: docker push realtimechat-snapshot-0.$GITHUB_REF
在 Build the Docker image
步骤构建这个 Dockerfile:
FROM alpine:latest
COPY ./build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar
当它尝试复制 jar 文件时出现此错误:
COPY failed: stat /var/lib/docker/tmp/docker-builder207778036/build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar: no such file or directory
注意*
在 - run: ls ./build/libs/
的步骤中,它实际上向我展示了 jar 文件:
Run ls ./build/libs/
realtimeChattingSystem-0.0.1-SNAPSHOT.jar
第 2 期
在此
我遇到了另一个问题
这是步骤:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- run: ./gradlew bootJar
- name: Login to Github regestry
run: docker login docker.pkg.github.com -u xxxxx -p xxxxx
- name: Build the Docker image
run: docker build . -t docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.$GITHUB_REF
- name: Push the image to github
run: docker push docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.$GITHUB_REF
在最后步我得到这个错误:
The push refers to repository [docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.refs/heads/master]
3aad04996f8f: Preparing
77cae8ab23bf: Preparing
error parsing HTTP 404 response body: invalid character 'p' after top-level value: "404 page not found\n"
您只需在工作流程开始时使用 actions/checkout
一次。当您在构建后再次使用它时,我认为它可能会将您的本地工作区重置回 GITHUB_SHA
并且您的 jar 文件将在此过程中被删除。
试试这个:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- run: gradle wrapper
- run: ./gradlew bootJar
- run: ls ./build/libs/
- name: Login to docker
run: docker login docker.pkg.github.com -u xxxxxx -p xxxxxx
- name: Build the Docker image
run: docker build . -t realtimechat-snapshot-0.$GITHUB_REF
- name: Tag the image
run: docker tag realtimechat-snapshot-0.$GITHUB_REF realtimechat-snapshot-0
- name: Push the image
run: docker push realtimechat-snapshot-0.$GITHUB_REF