0

I have a Dockerfile as below, tested to work on Unix systems. My client is trying to use the same on a windows but getting a Permission denied error on RUN ./gradlew clean deployNodes step.

How do I tweak my Dockerfile so that it works on a Windows system as well?

# Get java8
FROM openjdk:8-jre-slim
# Get gradle
FROM gradle:4.7.0-jdk8-alpine AS build
# Start as root to update the alpine image to install bash
USER root
# Add bash
RUN apk update && apk add bash
# Move the code, as owner
COPY --chown=gradle:gradle . /home/gradle/src
# Assign a working directory 
WORKDIR /home/gradle/src
# Run clean build
RUN ./gradlew clean deployNodes
# Expose ports for the services
EXPOSE 8080 5005 5006 5007 5008 5009 10001 10070
# Run the application
ENTRYPOINT ["build/nodes/runnodes"]

Edit:

The error is in :

/bin/sh: ./gradlew: Permission denied
The command '/bin/sh -C ./gradlew clean deploynodes' returned a non-zero code: 126

Following this thread I have made gradlew an executable: gradlew: Permission Denied

Community
  • 1
  • 1
pissall
  • 7,109
  • 2
  • 25
  • 45
  • this `WORKDIR /home/gradle/src` can not be the error . could you please post the error from the build command – LinPy Nov 08 '19 at 12:41
  • @LinPy I am trying to get the stack trace from the client. Meanwhile, he said that it was on step 7. Which could be `RUN ./gradlew clean deployNodes`.. Do you think this could cause the error? I will get back with the stack trace within a few hours – pissall Nov 08 '19 at 12:44
  • yes this could be `RUN ./gradlew clean deployNodes` – LinPy Nov 08 '19 at 12:46
  • @LinPy Thanks. I will update the question soon! – pissall Nov 08 '19 at 12:46
  • make sure also that they have all required files in the same folder as dockerfile so that will work `COPY --chown=gradle:gradle . /home/gradle/src` – LinPy Nov 08 '19 at 12:51
  • @LinPy Yes, the files are part of the repository, so I am sure about that. The `Dockerfile` is in the root directory of the repository – pissall Nov 08 '19 at 12:57
  • What's the actual error message? If it's a Windows host, can you check that the `gradlew` script has Unix (LF-only) line endings? – David Maze Nov 08 '19 at 12:58
  • @DavidMaze I do not have a Windows environment to test it on and I am not at all familiar with Windows. I ran `file gradlew` and got `gradlew: a /usr/bin/env sh script text executable, ASCII text` – pissall Nov 08 '19 at 13:02
  • Which docker version does your client use? – leopal Nov 08 '19 at 13:13
  • @LinPy I have updated the question. The line which we were suspicious about – pissall Nov 08 '19 at 23:40

1 Answers1

0

try to add:

WORKDIR /home/gradle/src
RUN apt-get update && apt-get install -y dos2unix
RUN dos2unix gradlew
RUN chmod +x gradlew
RUN ./gradlew clean deployNodes
LinPy
  • 16,987
  • 4
  • 43
  • 57