Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a simple grails app that runs fine by itself. It does not have a problem using the grails web profile with grails run-app

However, when I build a docker image out of the app, the grails commands, such as grails run-app --stacktrace or grails dependency-report --stacktrace sent to docker fail with 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 app. User is in the docker group.

docker build -t mygrailsapp .

DockerFile: (Build will fail on RUN grails dependency-report --stacktrace. If I remove that command, the build completes. However, the first time the app is run with default command it fails with same error.)

#
# 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 Mar 10 15:54:52 2016 OS/Arch: linux/amd64

like image 237
Ed J Avatar asked Apr 08 '16 13:04

Ed J


1 Answers

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.

like image 86
Yuri Avatar answered Oct 09 '22 13:10

Yuri