- Newest
- Most votes
- Most comments
The following is an elegant way to manage an .ebextensions directory and build with maven using the maven-assembly-plugin:
-
Create the
.ebextensions
directory under the root folder of your project (see screenshot) -
Create the following
wkhtmltox.config
file inside
files:
"/tmp/wkhtmltox.amazonlinux2.rpm":
mode: "000600"
owner: root
group: root
source: https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
commands:
install_wkhtmltox:
command: sudo yum localinstall -y /tmp/wkhtmltox.amazonlinux2.rpm
Note:
- adjust the URL according to the version and platform/cpu architecture
- added parameter
-y
to automatically confirm the installation when executed programatically - switched from
install
tolocalinstall
as we need return code 0 (success) also when the package is already installed (which will happen on the 2nd+ deployment) - syntax see [3]
- Extend
pom.xml
to use the maven-assembly-plugin to build azip
file which contains the applicationsjar
file and the.ebextensions
directory (without top level directory).
</build>
</plugins>
........
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<descriptors>
<descriptor>zip-with-ebextensions.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- In the project root directory create the corresponding configuration file for the assembly plugin named
zip-with-ebextensions.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>with-ebextensions</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>.ebextensions/**/*</include>
<!-- <include>Procfile</include> -->
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Note: can be extended by including a Procfile (see [2]) if needed.
- Build your project with
mvn package -Pproduction
Result:
The target directory should contain a zip file named <app_name_with_version>-with-ebextensions.zip
.
The contents should look like:
When you login to the underlying EC2 instance, you can see that wkhtmltopdf
was installed:
Final remark: The structure should also work, if you decide to deploy source code using e.g. the Elastic Beanstalk Command Line Interface (EB CLI), and build on the EC2 instance (see [1])
Related AWS Elastic Beanstalk documentation references:
Relevant content
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Hi Norman, the above worked perfectly fine! thank you so much for this answer, couldn't have asked for a better answer!
Excellent !!!