Package a Spring Boot App as RPM

Goals Package a Spring Boot Service as RPM Package Configure systemd integration Add install/uninstall hooks to create users, directories etc. Maven Setup <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.2</version> <relativePath/> </parent> <groupId>com.hascode</groupId> <artifactId>sample-app</artifactId> <version>1.0.0-SNAPSHOT</version> <name>sample-app</name> <properties> <java.version>11</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> (1) <groupId>de.dentrassi.maven</groupId> <artifactId>rpm</artifactId> <version>1.5.0</version> <executions> <execution> <goals> <goal>rpm</goal> </goals> </execution> </executions> <configuration> <packageName>sample-app</packageName> <skipSigning>true</skipSigning> <group>Application/Misc</group> <requires> <require>java-11-openjdk-headless</require> (2) </requires> <entries> <entry> (3) <name>/opt/sample-app</name> <directory>true</directory> <user>root</user> <group>root</group> <mode>0755</mode> </entry> <entry> (4) <name>/opt/sample-app/log</name> <directory>true</directory> <user>sample-app</user> <group>sample-app</group> <mode>0750</mode> </entry> <entry> (5) <name>/opt/sample-app/sample-app.jar</name> <file>${project.build.directory}/${project.build.finalName}.jar</file> <user>root</user> <group>root</group> <mode>0644</mode> </entry> <entry> (6) <name>/usr/lib/systemd/system/sample-app.service</name> <file>${project.basedir}/src/main/dist/sample-app.service</file> <mode>0644</mode> </entry> </entries> <beforeInstallation> (7) <file>${project.basedir}/src/main/dist/preinstall.sh</file> </beforeInstallation> <afterInstallation> <file>${project.basedir}/src/main/dist/postinstall.sh</file> </afterInstallation> <beforeRemoval> <file>${project.basedir}/src/main/dist/preuninstall.sh</file> </beforeRemoval> <license>All rights reserved</license> </configuration> </plugin> </plugins> </build> </project> ...

May 14, 2021 · 3 min · 567 words · Micha Kops

Prettier Code Formatter Configuration

Goals Setup Prettier for different environments / IDEs Run Prettier via git hooks Install Prettier Install via npm npm install --save-dev --save-exact prettier Add empty configuration file echo {}> .prettierrc.json Create Prettier ignore file .prettierignore: # Ignore artifacts: build coverage Format all project files with Prettier: npx prettier --write . Git Hooks Adding the following lines to the project’s package-json makes ESLint and Prettier run before each commit: { "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "**/*": "prettier --write --ignore-unknown" } } ...

May 14, 2021 · 1 min · 90 words · Micha Kops

Helm Snippets

Common operations Add Helm Repository helm repo add NAME URL e.g. for the Bitnami repository: helm repo add bitnami https://charts.bitnami.com/bitnami 1 ↵ "bitnami" has been added to your repositories List Repositories helm repo list 130 ↵ NAME URL bitnami https://charts.bitnami.com/bitnami Searching in a Helm Repository helm search repo wordpress NAME CHART VERSION APP VERSION DESCRIPTION bitnami/wordpress 15.2.30 6.1.1 WordPress is the world's most popular blogging ... bitnami/wordpress-intel 2.1.31 6.1.1 DEPRECATED WordPress for Intel is the most popu... ...

March 1, 2010 · 4 min · 697 words · Micha Kops

JavaScript Snippets

Creating a Nodejs Module 1) Create a package.json using npm init $ npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sane defaults. See npm help json for definitive documentation on these fields and exactly what they do. Use npm install <pkg> --save afterwards to install a package and save it as a dependency in the package.json file. ...

March 1, 2010 · 3 min · 484 words · Micha Kops

PHP Snippets

WordPress anonymize IP in comments Add as last line in theme’s functions.php: function wpb_remove_commentsip($comment_author_ip) { return '127.0.0.1'; } add_filter('pre_comment_user_ip','wpb_remove_commentsip'); WordPress remove version info Add as last line in theme’s functions.php: function remove_version_info() { return ''; } add_filter('the_generator', 'remove_version_info'); List of all WordPress Hooks

March 1, 2010 · 1 min · 43 words · Micha Kops