本文介绍了Dockerfile COPY失败:使用GitHub CI时,没有此类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过以下给定步骤使用GitHub Actions for Gradle项目:

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


Build the Docker image步骤中,它会构建以下Dockerfile:

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

,当它尝试复制jar文件时,出现此错误:

and when it tries to copy the jar file I get this error:

注意*

步骤中,它实际上向我显示了jar文件:

at - run: ls ./build/libs/ in the steps it actually shows me the jar file:

realtimeChattingSystem-0.0.1-SNAPSHOT.jar

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


最后步骤,我收到此错误:

At the last step I get this error:

3aad04996f8f:正在准备

3aad04996f8f: Preparing

77cae8ab23bf:正在准备

77cae8ab23bf: Preparing

解析HTTP 404响应正文时出错:顶级值后的无效字符"p": 找不到404页\ n"

error parsing HTTP 404 response body: invalid character 'p' after top-level value: "404 page not found\n"

推荐答案

在工作流程开始时,您只需使用一次- uses: actions/checkout@v1.构建后再次使用它时,我认为它可能是将本地工作空间重置为GITHUB_SHA,并且在此过程中将删除您的jar文件.

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.

尝试一下:

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

这篇关于Dockerfile COPY失败:使用GitHub CI时,没有此类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 05:41