Skip to content

Instantly share code, notes, and snippets.

View shinyay's full-sized avatar

Shinya Yanagihara shinyay

View GitHub Profile

Script for Spring Initilizr

$ curl -s https://gist.githubusercontent.com/shinyay/09eaf40b62fddd3a8d88ccadd3d4ba7d/raw/fbced50403b214e05f96414df512e635d5febc2f/initilizr.sh | bash && unzip template.zip && rm template.zip

Spring Boot Layers Tool

$ java -Djarmode=layertools -jar my-app.jar list
$ java -Djarmode=layertools -jar my-app.jar extract

You can see the following directories:

@shinyay
shinyay / spring-boot-container.md
Last active May 2, 2021 23:44
Maven and Gradle plugin can create an OCI image from an executable jar file using Cloud Native Buildpacks (CNB).

Spring Boot OCI Image using Clond Native Buildpacks

Maven

$ mvn spring-boot:build-image -Dspring-boot.build-image.imageName=docker.io/library/${project.artifactId}:${project.version}:${project.version}

Given-When-Then for Test

given-when-then is a commonly used style of specifying system behaviour in which your tests are split into three sections.

Given

Given is the section that lays out the pre-conditions for the test. ie whatever state you’re assuming the world to be in before you start.

When

When clause performs the action being tested.

@shinyay
shinyay / install-zsh.md
Created April 27, 2021 03:19
Install Zsh on Cloud Shell

Install Zsh on Google Cloud Shell

main() {

  # Install zsh
  sudo apt-get -qq update 
  sudo apt-get -qq install zsh -y

  # Use colors, but only if connected to a terminal, and that terminal
  # supports them.
@shinyay
shinyay / cloud-build-with-artifact-registry.md
Last active April 23, 2021 06:56
Build and Deploy for Artifact Registry

Cloud Build with Artifact Registry

$ gcloud builds submit --tag us-central1-docker.pkg.dev/(gcloud config get-value project)/<REPO>/<IMAGE>:<TAG>

Cloud Build with Buldpacks

Paketo Buildpack

$ gcloud builds submit \
    --pack builder=paketobuildpacks/builder:base,image=us-central1-docker.pkg.dev/(gcloud config get-value project)/shinyay-docker-repo/spring-app:0.0.1 .

Lightweight Java Docker Image

  • Debian
  • Zule
  • Alpine
  • AdoptOpenJDK

Debian

# First stage: JDK 11 with modules required for Spring Boot
FROM debian:stretch-slim as packager

Spring Application Properties with Evironment Variables

application.properties

app.prop=${APP_DATA:XXXXXXXX}

${ENV_VALUE:DEFAULT_VALUE}