Grails 3.1.4 and Docker - grails commands return “No profile found for name web”

◇◆丶佛笑我妖孽 提交于 2019-11-30 19:08:13
Yuri

I faced the same issue when I moved my Grails 3.1.4 application which uses the web profile to a fresh machine.

Doing gradle clean inside my application root directory triggered Grails Maven dependencies being downloaded and after that the grails command started working.

I fix it with next:

  1. Remove (or rename) .gradle directory
  2. Remove (or rename) gradle directory
  3. Remove (or rename) build directory

Now, I can run the app with grails run-app.

I have solve this by deleting build file. By deleting , and run again it might solve this problem.

I choose to just delete it because I can't even call out grails function.

Most likely you’ve landed on this page because you’ve searched for the error in a search engine and it brought you here.

Symptom: When you run “grails” under an existing project that you previously had (either on a different PC or from a source-control like GIT or SVN and you’ve mistakenly included the “build” directory).

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

For others with this issue, I just deleted (Or rather moved just in case I needed it back) my build folder and then ran again, it re downloaded all the dependencies and worked straight away

To improve the situation you can set the GRADLE_USER_HOME env var, with that you don't have to rm you build directory everytime you run docker, just before the first time, actually with deleting the build/.dependencies file does the trick

VOLUME ["/gradle"]
ENV GRADLE_USER_HOME /gradle

For me it worked by using command ./gradlew install after gradle clean and grails

grails command installed the dependencies and ./gradlew install resolved all the later errors

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

See example docker file snippet below:

...
# 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
...

I removed RUN dependency-report from the Dockerfile, and it fixed this issue.

However, this means the dependencies are no longer installed into the image, and must be downloaded when the container is first created. Not an ideal situation.

I don't understand why the web-profile is needed at run-app time. I thought the profile dictated the template used to set up the grails application. Once that's done why is it needed at run-time? What exactly is the "web profile". Is it a single file that could just be downloaded and added?

Another oddity is that an image created FROM mozart/grails , with RUN dependency-report, runs fine on docker toolbox for windows but fails on docker for linux. I don't understand how the same image would have different behavior on different docker platforms. I thought that was the point of docker.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!