相关疑难解决方法(0)

WAR中忽略了Elastic Beanstalk .ebextensions

我正在尝试更改client_max_body_size我的Elastic Beanstalk NGINX反向代理的属性,以允许上传更大的JPEG文件.因此,我将文件夹".ebextensions"添加到我的WAR文件的根目录(WAR文件还包括一个Spring Boot应用程序),并添加了一个文件".ebextensions/01_files.config",其中包含以下内容:

files:
  "/etc/nginx/conf.d/proxy.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
        client_max_body_size 20M;
Run Code Online (Sandbox Code Playgroud)

我通过Travis-CI将WAR文件部署到Elastic Beanstalk.但是,Elastic Beanstalk似乎忽略了该文件,因为上传文件大小(例如2MB)不起作用,并且在用SSH连接到实例并查找"/etc/nginx/conf.d/proxy.conf"文件时不存在.

我已经使用YAML验证器成功验证了上述内容.我知道,存在很多相关的问题,但不是那些似乎解决了我的问题.我还检查了根目录中的WAR文件中是否包含".ebextensions/01_files.config".当我检查"/ tmp/eb_extracted_jar"时,文件".ebextensions/01_files.config"也存在正确的内容.我甚至找不到"/var/log/cfn-init.log"中的任何错误.我注意到,在几秒钟内,文件"proxy.conf"在部署期间出现在"/etc/nginx/conf.d/"中,但之后它已被删除.

由于通过Travis-CI部署到Elastic Beanstalk,是否会出现此问题?还是我错过了一些重要的东西?

编辑: 我刚刚认识到,部署应用程序时,每次创建"proxy.conf"文件几秒钟,但几秒后它就会消失(ls -lsa在"/etc/nginx/conf.d/"中查看,请参阅"elasticbeanstalk"目录和"healthd_http.conf"的时间戳为13:34,"proxy.conf"的时间戳为13:43)

4 drwxr-xr-x 3 root root 4096  6. Dec 13:43 .
4 drwxr-xr-x 4 root root 4096  6. Dec 13:34 ..
4 drwxr-xr-x 2 root root 4096  6. Dec 13:34 elasticbeanstalk
4 -rw-r--r-- 1 root root  148  6. Dec 13:34 healthd_http.conf
4 -rwxr-xr-x 1 root root   26  6. Dec 13:43 …
Run Code Online (Sandbox Code Playgroud)

java nginx amazon-ec2 amazon-web-services spring-boot

4
推荐指数
1
解决办法
3120
查看次数

通过 maven for Spring Boot 应用程序为 AWS Beanstalk 创建 .ebextensions 的正确方法是什么

hosts在 GitLab CI/CD 管道期间,我们必须在 Spring Boot 应用程序的动态生成的 Elastic Beanstalk 实例中自定义文件。为此,我们需要提供一个.ebextensions包含如下配置文件的目录:

commands:
  01_add_hosts:
    command: echo 123.12.12.123 myhost.com >> /etc/hosts
Run Code Online (Sandbox Code Playgroud)

由于我们有一个spring boot应用程序,我们必须.ebextensions在我们的fat jar的根级别进行打包。所以,基本上我们解压缩 jar,添加 ebextensions 目录并将其压缩回来。这样我们就成功地在我们的 Gitlab 管道中实现了 Beanstalk 定制。

但是,要进行此过程,我们可以maven-antrun-plugin这样使用:

<!-- Bundle .ebextensions inside jar -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>prepare</id>
            <phase>package</phase>
            <configuration>
                <tasks>
                    <unzip src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.directory}/${project.build.finalName}" />
                    <copy todir="${project.build.directory}/${project.build.finalName}/" overwrite="false">
                        <fileset dir="./" includes=".ebextensions/**"/>
                    </copy>
                    <zip compress="false" destfile="${project.build.directory}/${project.build.finalName}.jar" basedir="${project.build.directory}/${project.build.finalName}"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

问题是这maven-antrun-plugin是 2014 年的旧插件,这看起来不是实现此捆绑 …

java amazon-web-services maven spring-boot gitlab-ci

0
推荐指数
2
解决办法
1169
查看次数