i tried to build docker image using docker-compose but i got this error
/bin/sh: 1: ./gradle: Permission denied
my Dockerfile is
FROM gradle:6.5.0-jdk11 AS TEMP_BUILD_IMAGE
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle.kts settings.gradle.kts $APP_HOME
COPY gradle $APP_HOME/gradle
COPY --chown=gradle:gradle . /home/gradle/src
USER root
RUN chown -R gradle /home/gradle/src
RUN ./gradle build || return 0
COPY . .
RUN ./gradle clean build
FROM openjdk:11-jdk
ENV ARTIFACT_NAME=app.jar
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME .
ENTRYPOINT exec java -jar ${ARTIFACT_NAME}
and this is what i got in the shell
D:\Docker>docker-compose up -d
Building config-server
Step 1/17 : FROM gradle:6.5.0-jdk11 AS TEMP_BUILD_IMAGE
---> a001e5b2850a
Step 2/17 : ENV APP_HOME=/usr/app/
---> Using cache
---> 07cf3a267c37
Step 3/17 : WORKDIR $APP_HOME
---> Using cache
---> 87be3841245e
Step 4/17 : COPY build.gradle.kts settings.gradle.kts $APP_HOME
---> Using cache
---> eff11fa2348e
Step 5/17 : COPY gradle $APP_HOME/gradle
---> Using cache
---> 10fca093f82e
Step 6/17 : COPY --chown=gradle:gradle . /home/gradle/src
---> b1f888f97818
Step 7/17 : USER root
---> Running in bde4f2d435fe
Removing intermediate container bde4f2d435fe
---> e8fba435db0c
Step 8/17 : RUN chown -R gradle /home/gradle/src
---> Running in d88ea2196f38
Removing intermediate container d88ea2196f38
---> b5b4727dd51f
Step 9/17 : RUN ./gradle build || return 0
---> Running in d218205301d9
/bin/sh: 1: ./gradle: Permission denied
Removing intermediate container d218205301d9
---> da37b296879b
Step 10/17 : COPY . .
---> e6cfac4a75a3
Step 11/17 : RUN ./gradle clean build
---> Running in 34480bf73106
/bin/sh: 1: ./gradle: Permission denied
ERROR: Service 'config-server' failed to build: The command '/bin/sh -c ./gradle clean build' returned a non-zero code: 126
how can i solve this error please?
You are using a base image which has gradle by itself. So, you don't need to copy gradle explicitly. Just remove ./ from gradle RUN.
RUN gradle build || return 0
COPY . .
RUN gradle clean build
Output
Step 9/17 : RUN gradle build || return 0
---> Running in fd470c45e443
Welcome to Gradle 6.5!
Here are the highlights of this release:
- Experimental file-system watching
- Improved version ordering
- New samples
For more details see https://docs.gradle.org/6.5/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 25s
1 actionable task: 1 executed
Removing intermediate container fd470c45e443
---> dd4056a53129
Step 10/17 : COPY . .
---> 3a46c7e9d9bb
Step 11/17 : RUN gradle clean build
---> Running in c3341e91aef0
Welcome to Gradle 6.5!
Related
I'm currently working on DXVKoTool, a Compose application built with Kotlin.
As I want it to be easily available on the Steam Deck, I try to build a Flatpak off it.
Basically what I wanted to do is packaging it (with jpackage) and use the built binaries when building the Flatpak.
My building process would look like this:
./gradlew packageAppImage
flatpak-builder build/release/main/flatpak dev.datlag.DXVKoTool.yml --force-clean
The packageAppImage command produces an output like this:
{project-dir}
|-build
|-release
|-main
|-app
|-DXVKoTool
|-bin
| |-DXVKoTool {executable}
|-lib
|-{resources, binaries, etc.}
However building the Flatpak is somehow driving me crazy and I'm not sure what's wrong.
My flatpak build YAML file:
app-id: dev.datlag.DXVKoTool
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: DXVKoTool
modules:
- name: dxvkotool
buildsystem: simple
build-commands:
- mkdir -p /app/lib/
- install -Dm755 ./build/release/main/app/DXVKoTool/bin/DXVKoTool /app/bin/DXVKKoTool
- cp -R ./build/release/main/app/DXVKoTool/lib/* /app/lib/
sources:
- type: file
path: ./build/release/main/app/DXVKoTool/bin/DXVKoTool
- type: dir
path: ./build/release/main/app/DXVKoTool/lib/
When I run the flatpak-builder command, it's stopping with the following error:
Emptying app dir 'build/release/main/flatpak'
Downloading sources
Starting build of dev.datlag.DXVKoTool
Cache hit for openjdk, skipping build
Cache miss, checking out last cache hit
========================================================================
Building module git in /home/jeff/Projects/Multiplatform/DXVKoTool/.flatpak-builder/build/git-1
========================================================================
Running: mkdir -p /app/lib/
Running: install -Dm755 ./build/release/main/app/DXVKoTool/bin/DXVKoTool /app/bin/DXVKoTool
install: cannot stat './build/release/main/app/DXVKoTool/bin/DXVKoTool': No such file or directory
When I change the config to the following:
app-id: dev.datlag.DXVKoTool
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: DXVKoTool
modules:
- name: dxvkotool
buildsystem: simple
build-commands:
- mkdir -p /app/lib/
- install -Dm755 DXVKoTool /app/bin/DXVKoTool
- cp -R lib/* /app/lib/
sources:
- type: file
path: ./build/release/main/app/DXVKoTool/bin/DXVKoTool
- type: dir
path: ./build/release/main/app/DXVKoTool/
The building works but after installing the outcome it doesn't start with this error:
bwrap: execvp DXVKoTool: No such file or directory
Would be nice if someone can help me building the Flatpak.
I have a problem similar to Run (Docker) Test Container in gitlab with Maven. The difference is that rather than my script running mvn directly it runs a docker multistage build that runs the test inside of the docker image. Unfortunately this doesn't appear to work for the PostgreSQL Test Container.
Dockerfile
#############
### build ###
#############
# base image
FROM maven:3-jdk-11 as build
# set working directory
WORKDIR /app
# add app
COPY . .
RUN export MAVEN_OPTS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" && export MAVEN_CLI_OPTS="-B -U --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
RUN mvn $MAVEN_CLI_OPTS clean install
############
### prod ###
############
# Yea this isn't right, but it crashes before it gets to this point. This is for example purposes only.
FROM openjdk:15-jdk-alpine
COPY --from=build /app/reproducer-testcontainer/target/reproducer-testcontainer.jar /reproducer-testcontainer.jar
CMD java -jar reproducer-testcontainer.jar
When I run mvn clean install it works properly and runs my test using the PostgreSQL Test Container. However, when I run docker build . it fails at the mvn clean install step with the below stack trace.
Stack trace:
13:05:01.250 [main] ERROR org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - ping failed with configuration Environment variables, system properties and defaults. Resolved:
dockerHost=unix:///var/run/docker.sock
apiVersion='{UNKNOWN_VERSION}'
registryUrl='https://index.docker.io/v1/'
registryUsername='root'
registryPassword='null'
registryEmail='null'
dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=root,registryPassword=<null>,registryEmail=<null>,registryUrl=https://index.docker.io/v1/,dockerConfigPath=/root/.docker,sslConfig=<null>,apiVersion={UNKNOWN_VERSION},dockerConfig=<null>]'
due to org.rnorth.ducttape.TimeoutException: Timeout waiting for result with exception
org.rnorth.ducttape.TimeoutException: Timeout waiting for result with exception
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:51)
<snip>
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.io.IOException: com.sun.jna.LastErrorException: [2] No such file or directory
at org.testcontainers.shaded.org.scalasbt.ipcsocket.UnixDomainSocket.<init>(UnixDomainSocket.java:62)
<snip>
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.sun.jna.LastErrorException: [2] No such file or directory
at org.testcontainers.shaded.org.scalasbt.ipcsocket.UnixDomainSocketLibrary.connect(Native Method)
at org.testcontainers.shaded.org.scalasbt.ipcsocket.UnixDomainSocket.<init>(UnixDomainSocket.java:57)
... 35 common frames omitted
In my CI pipeline I'd like to only run docker build . and not worry about having another stage that does the mvn clean install.
How do I fix the configuration to get the java PostgreSQL Testcontainers to work inside of a Docker build so that I can use it in a multi-stage build?
Full Code example: https://gitlab.com/raymondcg/reproducer-testcontainer
Not really Testcontainers related.
Testcontainers requires a valid Docker daemon. When you build images, there is no daemon mounted into the image build context.
You can easily verify that by doing:
RUN curl --unix-socket /var/run/docker.sock http:/_/_ping
Make this command return "OK" (no need to run the Testcontainers code), and your tests will pass as well.
You can overwrite testcontainers default docker host by adding:
ENV DOCKER_HOST=tcp://host.docker.internal:2375
to your build stage.
While developing an app I came into following error. I tried downgrading the java version from 11 to 8, but that wasn't helpful.
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
How I solved this problem:
First, make sure that I have %java_home% variable set and also %path% has the java sdk included.
How to setup Java environment variables
Second, Go to your android folder and run this command:
C:\Projects\myproject\android>gradlew.bat app:installDebug.
Unzipping
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip
to
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Exception in thread "main" java.util.zip.ZipException: error in
opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:215)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:75)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
As you can see that my gradle download is corrupt. All you have to do is delete this folder and rerun the command.
C:\Projects\myproject\android>gradlew.bat app:installDebug
Downloading
https://services.gradle.org/distributions/gradle-4.10.2-all.zip
...............................................................................................................
Unzipping
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip
to
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Welcome to Gradle 4.10.2!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the plugins {} block
For more details see https://docs.gradle.org/4.10.2/release-notes.html
Now, you can go back to your react native project and run
react-native run-android
info JS server already running. info Building and installing the app
on the device (cd android && gradlew.bat app:installDebug)...
Task :app:installDebug 01:03:18 V/ddms: execute: running am get-config 01:03:18 V/ddms: execute 'am get-config' on 'emulator-5554'
: EOF hit. Read: -1 01:03:18 V/ddms: execute: returning Installing APK
'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug 01:03:18
D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
01:03:18 D/Device: Uploading file onto device 'emulator-5554' 01:03:18
D/ddms: Reading file permision of
C:\Projects\xx\android\app\build\outputs\apk\debug\app-debug.apk
as: rwx------ 01:03:18 V/ddms: execute: running pm install -r -t
"/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'pm install
-r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning 01:03:19 V/ddms: execute:
running rm "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute
'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit.
Read: -1 01:03:19 V/ddms: execute: returning Installed on 1 device.
BUILD SUCCESSFUL in 9s 27 actionable tasks: 1 executed, 26 up-to-date
info Running
C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on
emulator-5554
(C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 shell am start -n
com.myproject/com.myproject.MainActivity)... Starting:
Intent { cmp=com.myproject/.MainActivity }
Try running this command inside your project file
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
after that
cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
always gradlew clean before run react-native-run-android
the above command basically cleans up the gradle and previous builds.
for ENOENT Error
Check if $ yarn start works. The metro bundler wasn't able to run on port 8081 for me and I needed to run $ killall node
EDIT:
Also update the gradle-wrapper.properties
add
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
remove following code from build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '5.2.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
after that
cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
always gradlew clean before run react-native-run-android the above command basically cleans up the gradle and previous builds.
You're good to go!
Just run sudo react-native run-android and it will build and install ./gradlew app:installDebug inside android directory for you.
I had this issue too and I was able to fix it by creating a new project in react-native 0.57.3 using the command:
react-native init --version="0.57.3" MyNewApp
You have to update the gradle-wrapper.properties file to use the newest version of gradle:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
And remove this block from build.gradle file:
task wrapper(type: Wrapper) {
gradleVersion = '5.2.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
Then run a gradlew clean on the android folder and everything should work.
I had this issue too and I was able to fix it by run ./gradlew app:installDebug in android folder .
In my case, I uninstalled my java jdk17 and installed java jdk11. It worked for me few seconds ago. Really happy :)))
I had this issue myself, it eventually went away after I uninstalled and re-installed android studio and gradle, but a few other things you could try first
1: Setting GRADLE_USER_HOME in environment variables (if on windows)
2: Downgrade to react-native 0.57.0
3: Make sure you have the correct permissions to run the command and access files
4: Make sure your gradle files are synced correctly, and that location of gradle and the android skd are correct within project structure offline mode
5: Check gradle for updates
(Assuming you are using android studio)
Good luck
The problem is on file:
nameyourapp/android/local.properties
you have to substitute with the correct path: /Users/nameUser/AppData/Local/Android/sdk
I have the same error I just uninstall the JDK old version and install the latest version from https://www.oracle.com/java/technologies/javase-downloads.html and now it's working.
Open your settings.grandler file in the android folder
Change the \ to /
Save the file
Run the command react-native run-android
I have integrated CircleCI to run Espresso test on my app. I have taken the following circle.yml file from another online github repo and changed the android build tools and android version to 25. However when I run the build on the circleCI server, I get the following error. I have granted the execution permission in yml file.
My app Repo structure is
Action failed: gradle dependencies
export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
bash: line 2: ./gradlew: Permission denied
export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
returned exit code 126
Action failed: gradle dependencies
circle.yml:
general:
artifacts:
- /home/ubuntu/MyRideApp/app/build/outputs/apk/
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
ADB_INSTALL_TIMEOUT: 240
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3072M -XX:+HeapDumpOnOutOfMemoryError"'
dependencies:
pre:
- chmod +x gradlew
- touch app/google-services.json
- echo y | android update sdk --no-ui --all --filter "tools,android-25,build-tools-25.0.2,platform-tools,extra-android-m2repository,extra-android-support,extra-google-m2repository,extra-google-google_play_services"
cache_directories:
- /usr/local/android-sdk-linux/tools
- /usr/local/android-sdk-linux/build-tools/25.0.2
override:
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
# Comment the test stuff out (or remove it) if you don't need it.
test:
pre:
- emulator -avd circleci-android23 -no-audio -no-window:
background: true
parallel: true
- circle-android wait-for-boot
# unlock emulator
- sleep 30
- adb shell input keyevent 82
override:
# - ./gradlew clean assemble
# This will run the tests:
- ./gradlew assemble connectedDebugAndroidTest -PdisablePreDex --console=plain --info
post:
- cp -r app/build/outputs $CIRCLE_ARTIFACTS
- cp -r app/build/outputs/androidTest-results/connected/ $CIRCLE_TEST_REPORTS
gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
/gradle/wrapper does contain gradle-wrapper.jar
A solution is on the circleCI forum.
You have to add execution right like the following : chmod +x gradlew
It works for me.
Here is an example of my circleci.yml :
machine:
java:
version: oraclejdk8
dependencies:
override:
- chmod +x gradlew
- ./gradlew dependencies
test:
override:
- chmod +x grailsw
- ./grailsw test-app --non-interactive
post:
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/target/test-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
Steps:
create new project with start.spring.io
run it localy - works
run gradle task jar
push jar to bluemix cf push demoWar.jar
Downloaded app package (20.1M) Staging... None of the buildpacks
detected a compatible application Exit status 222 Staging failed:
Exited with status 222 Destroying container
FAILED Error restarting application: NoAppDetectedError
TIP: Buildpacks are detected when the "cf push" is executed from
within the dire ctory that contains the app source code.
Try two things:
1. Use the -p command to target your deployable artifact. This would look something like cf p APP_NAME -p PATH_TO_YOUR_WAR. I usually chain my build and deploy commands so: mvn clean package && cf p APP_NAME -p PATH_TO_YOUR_WAR.
If this doesn't work then you can specify a build pack. So cf p APP_NAME -p PATH_TO_YOUR_WAR -b SOME_BUILDPACK. You can see the available build packs by calling cf buildpacks.
Hope this helps.
When deploying first time your app on cloud foundry then following command will not work
cf push TestService
you need to use following command
cf push -p TestService-0.0.1-SNAPSHOT.jar testService
Useful link :
https://discuss.pivotal.io/hc/en-us/articles/226273647-Troubleshooting-error-None-of-the-buildpacks-detected-a-compatible-application-exit-status-222-
https://docs.cloudfoundry.org/buildpacks/detection.html
Else add manifest.yml on root
applications:
- name: Demo
memory: 2G
disk_quota: 2G
instances: 1
path: target/demo-local-0.0.1-SNAPSHOT.jar
env:
SPRING_PROFILES_ACTIVE : "dev"
routes:
- route: demo.app.dev.vk.vaquar.khan.com
after that go to path and run cf push < JAR_NAME>