Grails 3.1.4 and Docker - grails commands return "No profiles found for network name"

I have a simple grails application that works fine on its own. It has no problem using grails web page profile with grails run-app

However, when I create the docker image from the application, grails commands such as grails run-app --stacktrace or grails dependency-report --stacktrace sent to docker fail using stacktrace:

 | Error Error occurred running Grails CLI: No profile found for name [web]. (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.) java.lang.IllegalStateException: No profile found for name [web]. at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:507) at org.grails.cli.GrailsCli.initializeApplication(GrailsCli.groovy:308) at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:271) at org.grails.cli.GrailsCli.main(GrailsCli.groovy:162) | Error Error occurred running Grails CLI: No profile found for name [web]. 

Docker Build Command: Run from the root of the grails application. The user is in the docker group.

 docker build -t mygrailsapp . 

DockerFile: (The line will fail in the RUN grails-dependency-report -stacktrace command. If I remove this command, the assembly will fail. However, the first time the application starts with the default command, the same error occurs.)

 # # My Dockerfile # # https://github.com/dockerfile/java # https://github.com/dockerfile/java/tree/master/oracle-java8 # https://hub.docker.com/r/mozart/grails/ # Pull base image. FROM ubuntu RUN apt-get update # install apt-get-repository RUN \ apt-get install -y software-properties-common wget unzip git # Install Java. RUN \ echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \ add-apt-repository -y ppa:webupd8team/java && \ apt-get update && \ apt-get install -y oracle-java8-installer rm -rf /var/lib/apt/lists/* && \ rm -rf /var/cache/oracle-jdk8-installer # Define working directory. WORKDIR /data # Define commonly used JAVA_HOME variable ENV JAVA_HOME /usr/lib/jvm/java-8-oracle # Set customizable env vars defaults. # Set Grails version (default: 3.1.4; min: 3.0.0; max: 3.1.4). ENV GRAILS_VERSION 3.1.4 # Install Grails WORKDIR /usr/lib/jvm # TODO put grails zips on your own server with decent bandwidth RUN wget https://github.com/grails/grails-core/releases/download/v$GRAILS_VERSION/grails-$GRAILS_VERSION.zip && \ unzip grails-$GRAILS_VERSION.zip && \ rm -rf grails-$GRAILS_VERSION.zip && \ ln -s grails-$GRAILS_VERSION grails # Setup Grails path. ENV GRAILS_HOME /usr/lib/jvm/grails ENV PATH $GRAILS_HOME/bin:$PATH # Create App Directory RUN mkdir /app # Set Workdir WORKDIR /app # Copy App files COPY . /app # Run Grails dependency-report command to pre-download dependencies but not # create unnecessary build files or artifacts. RUN grails dependency-report --stacktrace # Set Default Behavior ENTRYPOINT ["grails"] CMD ["run-app"] 

Setup:

Ubuntu 14.04 LTS 64

Jave: Oracle JDK 1.8.0_77 64

Via sdkman 4.0.32:

Grails 3.14 Groovy 2.4.6 Gradle 2.12

Docker Client: Version: 1.10.3 API version: 1.22 Go version: go1.5.3 Git commit: 20f81dd Built: Thu 10 Mar 15:54:52 2016 OS / Arch: linux / amd64

+7
docker grails gradle
source share
7 answers

I had the same problem when I moved the Grails 3.1.4 application which uses the web profile for a new machine.

Running gradle clean inside the root directory of the application launches the downloaded Grails Maven dependencies and after that the grails starts working.

+19
source share

For others with this problem, I simply deleted (or rather moved in case I needed it) my collection folder, and then started it again, downloaded all the dependencies and immediately worked

+2
source share

I will fix it as follows:

  • Delete (or rename) .gradle directory
  • Delete (or rename) gradle directory
  • Delete (or rename) build directory

Now I can start the application using grails run-app .

+2
source share

I solved this by deleting the build file. By uninstalling and running it again, it can solve this problem.

I want to just delete it because I cannot even call the grails function.

Most likely, you got to this page because you were looking for a mistake in the search engine, and it brought you here.

Symptom: when you start "grails" within the framework of an existing project that you previously had (either on another PC, or from a source control, such as GIT or SVN, and you mistakenly included the "build" directory).

Please refer to this https://mythinkpond.com/2016/11/29/grails-no-profile-found-for-name-web-illegalstateexception/

+2
source share

To improve the situation, you can set GRADLE_USER_HOME env var, so that you do not need to create the rm directory every time you start docker, before the first launch, in fact, when you delete the build / .dependencies file, the trick

 VOLUME ["/gradle"] ENV GRADLE_USER_HOME /gradle 
+1
source share

I have found the answer. I had to download grails profiles from github and set them to $ GRAILS_HOME. I placed this step right after setting the Grails environment variables in the docker file.

The following is an example of a docker file fragment:

 ... # Setup Grails path. ENV GRAILS_HOME /usr/lib/jvm/grails ENV PATH $GRAILS_HOME/bin:$PATH # Setup grails profiles RUN wget https://codeload.github.com/grails/grails-profile-repository/zip/master && \ unzip master && \ mv grails-profile-repository-master/profiles/ $GRAILS_HOME && \ rm -rf master && \ rm -rf grails-profile-repository-master ... 
0
source share

I deleted the RUN error report from the Docker file and it fixed this problem.

However, this means that dependencies are no longer installed in the image and must be loaded when creating the container. Not an ideal situation.

I don’t understand why a web profile is needed during application launch. I thought the profile dictated the pattern used to configure the grails application. After that, why is it needed at runtime? What is a web profile? Is this the only file you can simply download and add?

Another oddity is that the image created by FROM mozart / grails, with a RUN dependency message, works fine on the docker toolbar for windows, but doesn't work on docker for linux. I don’t understand how the same image will have different behavior on different docker platforms. I thought it was a docker point.

Sorry for providing more questions than answers here, but hoping to get a better understanding of all of this.

0
source share

All Articles