Grails 3.1.4和Docker-grails命令返回“找不到名称Web的配置文件". [英] Grails 3.1.4 and Docker - grails commands return "No profile found for name web"

查看:144
本文介绍了Grails 3.1.4和Docker-grails命令返回“找不到名称Web的配置文件".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的grails应用程序,它本身运行良好.将grails Web配置文件与grails run-app

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

但是,当我从应用程序中构建docker映像时,发送到docker的grails命令(例如grails run-app --stacktracegrails dependency-report --stacktrace)会因stacktrace失败:

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命令: 从grails应用程序的根目录运行. 用户在docker组中.

Docker Build command: Run from the root of the grails app. User is in the docker group.

docker build -t mygrailsapp .

DockerFile: (在RUN上构建将失败,失败依赖项--report --stacktrace.如果删除该命令,则构建完成.但是,第一次使用默认命令运行该应用程序时,它将失败,并出现相同的错误.)

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"]

设置:

Ubuntu 14.04 LTS 64

Ubuntu 14.04 LTS 64

Jave:Oracle JDK 1.8.0_77 64

Jave: Oracle JDK 1.8.0_77 64

通过sdkman 4.0.32:

Via sdkman 4.0.32:

Grails 3.14 Groovy 2.4.6 摇篮2.12

Grails 3.14 Groovy 2.4.6 Gradle 2.12

Docker 客户: 版本:1.10.3 API版本:1.22 Go版本:go1.5.3 Git提交:20f81dd 建成:2016年3月10日星期四15:54:52 操作系统/Arch:linux/amd64

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

推荐答案

当我将使用web配置文件的 Grails 3.1.4 应用程序移动到新计算机上时,遇到了同样的问题.

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

在应用程序根目录中执行gradle clean触发了Grails Maven依赖项的下载,此后grails命令开始工作.

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

这篇关于Grails 3.1.4和Docker-grails命令返回“找不到名称Web的配置文件".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆