Dockerfile COPY failed: stat no such file, when using GitHub CI - java

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"

You only need to use actions/checkout 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#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

Related

Generated txt file not pushing to GitHub repo

My question is: I have Maven Project that generates txt file and I'm running it from GitHub Actions. Generated files not pushing into GitHub repo.
Do I need to add some script into yaml?
name: Java CI with Maven
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Set up JDK 11
uses: actions/setup-java#v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean test -DsuiteXMLFILE=testng.xml
These two files not updating at all.
All paths are correct (used relative path).

Docker build stuck in Gradle task

When I try to run this Docker image it stays stuck forever:
FROM gradle:7.4.2-jdk11 as build
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false"
WORKDIR /usr/src/app
COPY . .
RUN ./gradlew shadowJar
FROM adoptopenjdk:latest
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build/libs ./
This is the docker-compose.yml file:
version: "3.8"
services:
slack_bot:
container_name: slack_bot
platform: linux/amd64
build: .
ports:
- "8000:8000"
environment:
PORT: 8000
command: java -jar build/libs/slack-bot-1.0-SNAPSHOT-all.jar
This is the output of docker-compose up (stuck there with the seconds increasing forever):
=> [build 4/4] RUN ./gradlew shadowJar 803.1s
=> => # - Aggregated test and JaCoCo reports
=> => # - Marking additional test source directories as tests in IntelliJ
=> => # - Support for Adoptium JDKs in Java toolchains
=> => # For more details see https://docs.gradle.org/7.4.2/release-notes.html
=> => # To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
=> => # Daemon will be stopped at the end of the build
I tried multiple variations including turning on/off the Docker daemon, different Docker images, increasing JVM memory, etc. without success. I'm using the latest Docker (4.8.2) on an Apple M1. Any hints?

Any changes made by using the GitHub Actions not reflecting into project files(Maven commands)

I'm developing a maven project and using GitHub Actions to build and deploy the package into GitHub. I'm using the maven command to update the version inside the workflow. Here is the workflow
name: Maven Package
on:
push:
branches: ['beta']
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v2
with:
java-version: '11'
distribution: 'adopt'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Semantic Version
run: |
mvn versions:set -DnewVersion=1.3.1-beta
git config remote.origin.url https://github.com/<username>/<repo>.git
git config --global user.name <username>
git config --global user.email <email>
git add -A
git commit -am "version beta update"
- name: Push changes
uses: ad-m/github-push-action#master
with:
github_token: ${{ github.token }}
branch: ${{ github.ref }}
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
when I push the code to the beta branch. My workflow is changing the version and deploying the package, but it's not updating the version inside the pom.xml file. When I execute the command in the terminal it is updating the version inside pom.xml. But when I'm executing it by using Github Actions it is changing the version but not updating the pom file version and also not updating the target file. What should I do?
I need to change the version inside pom.xml using the GitHub-Actions workflow.
Thank you.

"b'OCI runtime create failed: container_linux.go:380?

Client Error: Bad Request ("b'OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/usr/lib/jvm/java-8-openjdk-amd64/bin/java": stat /usr/lib/jvm/java-8-openjdk-amd64/bin/java: no such file or directory: unknown'")
this my error ,I cann't fix this ,when I use docker-compose and docker
my version
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:45:44 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:44:15 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.18.0
GitCommit: fec3683
docker compose version
docker-compose version 1.25.0, build unknown
docker-py version: 4.1.0
CPython version: 3.8.10
OpenSSL version: OpenSSL 1.1.1f 31 Mar 2020
Dockerfile
FROM openjdk:8-jdk
# Install maven
RUN apt-get update
RUN apt-get install -y maven
WORKDIR /code
# Prepare by downloading dependencies
ADD pom.xml /code/pom.xml
RUN ["mvn", "dependency:resolve", "-U"]
RUN ["mvn", "verify"]
# Adding source, compile and package into a fat jar
ADD src /code/src
RUN ["mvn", "package", "-DskipTest=True", "-Dmaven.javadoc.skip=true", "-Dmaven.test.skip=true", "--offline"]
EXPOSE 4458
# CMD ["ls", "-la", "target/"]
ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-jar", "target/pbft-jar-with-dependencies.jar"]
docker-compose.yml
version: '2'
services:
node_java:
extends:
file: docker-compose.node-java.yml
service: node
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
NODE_DEBUG: "False"
docker-compose.node-java.yml
version: '2'
services:
node:
build: .
environment:
NODE_PORT: 4458
command: ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"]
# restart: "unless-stopped"
# stdin_open: true
node-pi:
build:
context: .
dockerfile: ARM.Dockerfile
environment:
NODE_PORT: 4458
Any suggestion will help !!!
thank you very much
I think the path to the java executable in the image is different than the one you used.
Can you try and replace the path in your DOCKERFILE like so?
ENTRYPOINT ["/usr/local/openjdk-8/bin/java", "-jar", "target/pbft-jar-with-dependencies.jar"]
I used the following procedure to find that out:
docker pull openjdk:8-jdk
docker run openjdk:8-jdk
docker container ls -a
mkdir -p /tmp/snapshot
cd /tmp/snapshot
docker export 7778d9fa6ce9> snapshot.tar
tar -xvf snapshot.tar
find . -type f -name java
modify Old java site
to this
/usr/local/openjdk-8/bin/java
it is error
second
I fix this using old version docker and docker-compose
modify version :
Since my project is 2017, I choose the old version of docker and the docker compose version close to 2017
detail version
docker-ce | 5:18.09.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker compose
https://github.com/docker/compose/releases/tag/1.16.1
1.16.1

Docker build doesn't run in gitlab CI/CD

docker build --pull -t "$DOCKER_REGISTRY_IMAGE" . ``` in my YML file it gives me the following error
#7 sha256:dfa2ef75c7954aaee8f870047cbaf47a407eb186847ff19b01de4c198fb4fa00
#7 ERROR: lstat /var/lib/docker/tmp/buildkit-mount254857695/build/libs: no such file or directory
------
> [2/2] COPY build/libs/*.jar app.jar:
------
lstat /var/lib/docker/tmp/buildkit-mount254857695/build/libs: no such file or directory
When I run the same command in IntelliJ it works.
This is my YML file (The docker part)
deploy-docker:
image: docker:latest
stage: deploy-docker
services:
- docker:dind
before_script:
- docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PSW"
script:
- cd goatpool-backend
- docker build --pull -t "$DOCKER_REGISTRY_IMAGE" .
- docker push "$DOCKER_REGISTRY_IMAGE"
this is my Dockerfile content:
FROM openjdk:11
VOLUME /tmp
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Categories

Resources