问题
I am using GitHub Actions for Gradle project with this given steps:
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
at Build the Docker image
step it build this 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
and when it tries to copy the jar file I get this error:
COPY failed: stat /var/lib/docker/tmp/docker-builder207778036/build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar: no such file or directory
NOTE*
at - run: ls ./build/libs/
in the steps it actually shows me the jar file:
Run ls ./build/libs/
realtimeChattingSystem-0.0.1-SNAPSHOT.jar
Issue #2
after doing the changes in this post
I faced another issue
this is the steps:
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
At the last step I get this error:
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"
回答1:
You only need to use - uses: actions/checkout@v1
once at the start of your workflow. When you use it again after building I think it's probably resetting your local workspace back to the GITHUB_SHA
and your jar file is being deleted in the process.
Try this:
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/
- 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
来源:https://stackoverflow.com/questions/58920140/dockerfile-copy-failed-stat-no-such-file-when-using-github-ci