Skip to content

Instantly share code, notes, and snippets.

View jonashackt's full-sized avatar
:octocat:
TDD & CI for IaC FTW!

Jonas Hecht jonashackt

:octocat:
TDD & CI for IaC FTW!
View GitHub Profile
@jonashackt
jonashackt / docker-healthcheck-java.md
Last active May 5, 2021 15:46
Creating our own Java-based Docker Healthcheck without curl

Paketo.io / CloudNativeBuildPack created Container image doesn't have curl installed - and this is for good reasons (see https://stackoverflow.com/a/65393843/4964553 & https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/).

So we need another aproach... As suggested we should use the container inherited language (here: Java/JDK) to write our own healthcheck.

Creating our own Java-based Healthcheck without curl

So let's look at this great article https://mflash.dev/blog/2021/03/01/java-based-health-check-for-docker/ , where Naiyer explains how to write a simple healthcheck based on Java 11+

Here's my adoption leveraging an argument to provide a specific port. Just look into HealthCheck.java:

@jonashackt
jonashackt / paketo-cloud-native-buildpacks-cheat-sheet.sh
Last active December 21, 2020 13:42
Cheat sheet for Cloud Native Buildpacks / Paketo building Spring Boot apps
# Samples:
https://github.com/buildpacks/samples
# We can override the default ENTRYPOINT in a CNB build container
see https://buildpacks.io/docs/app-developer-guide/run-an-app/#user-provided-shell-process
So we need to know the default launch process of a CNB build Spring Boot container - and then add the needed installation command
@jonashackt
jonashackt / github-actions-maven.yml
Created November 29, 2020 20:09
DevOps lecture: GitHub actions configuration
name: devopsdemo
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
@jonashackt
jonashackt / HelloRouter.java
Last active November 29, 2020 19:51
DevOps lecture: Spring Boot reactive router & handler code
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.*;
import reactor.core.publisher.Mono;
@Component
public class HelloRouter {
@jonashackt
jonashackt / HelloRouterTest.java
Last active November 29, 2020 19:50
DevOps lecture: Spring Boot reactive test code
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.reactive.server.WebTestClient;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class HelloRouterTest {
@Test void
@jonashackt
jonashackt / sdkman-cheatsheet.sh
Last active January 6, 2023 15:20
SDKMan cheatsheet
# Use another Java version as currently active
sdk list java
================================================================================
Available Java Versions
================================================================================
Vendor | Use | Version | Dist | Status | Identifier
--------------------------------------------------------------------------------
AdoptOpenJDK | | 15.0.1.j9 | adpt | | 15.0.1.j9-adpt
| | 15.0.1.hs | adpt | installed | 15.0.1.hs-adpt
| | 14.0.2.j9 | adpt | | 14.0.2.j9-adpt
@jonashackt
jonashackt / mac-cheatsheet.sh
Last active November 4, 2020 09:11
Collecting some Mac related terminal commands I regularly need
# Show all processes that use a port
lsof -i 4tcp
# or
netstat -anvp tcp | awk 'NR<3 || /LISTEN/'
@jonashackt
jonashackt / backup_osmc.md
Last active September 26, 2020 16:35
Raspberry OSMC Backup
@jonashackt
jonashackt / group_vars-your_host_group.yml
Last active June 12, 2020 08:14
Elegant way to access protected environment variables from GitLab CI Pipelines with Ansible (and to have a concept for semi-secret vars for test & local stages)
# for local & test deployment, we want to directly insert the values for ease of use for the developers
# group_vars/local.yml
my:
foo:
variable: "semi-secret-value-123456"
# for staging & live, we want to read the values from protected GitLab variables (only readable by Maintainer & Owner roles),
# which are accessible from within GitLab CI Pipeline via environment variables - and thus with the help of
# https://docs.ansible.com/ansible/latest/plugins/lookup/env.html like this: "{{ lookup('env','STAGE_MY_FOO_ENV_SECURED') }}"
@jonashackt
jonashackt / extract_liferay7_dxp_from_dockerhub.sh
Created March 25, 2020 14:09
How to extract the fully working Liferay 7 DXP bundle from the hub.docker.com/r/liferay/dxp Docker Image
# There's an official CE and DXP Liferay Docker image availabel on Docker Hub.
# The problem with DXP: The liferay bundle .tar.gz isn't downloadable from Sourceforge or GitHub - and even if you have
# a subscription and access to Liferay Enterprise Webportal https://customer.liferay.com/en/downloads
# there are maybe already newer Releases, that are only available in fresh Docker images
# But you can extract a liferay bundle .tar.gz from those Docker images! Here's how:
# Run a Docker Container with the newest DXP image from https://hub.docker.com/r/liferay/dxp , that you want to have as a bundle
# ATTENTION: Watch out for build numbers! A 7.2.10-dxp-4-202003240401 means it is the latest version 7.2.10 Fix Pack 4
docker run liferay/dxp:7.2.10-dxp-4-202003240401