Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spring Boot Admin pipeline, update SBA, Eureka and Config Server deps #36

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/build_config_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ permissions:
contents: 'read'

env:
IMAGE_NAME: config-server
REGISTRY: ${{ github.event_name == 'pull_request' && vars.DOCKER_REGISTRY || 'steeltoeoss' }}
IMAGE_NAME: ${{ github.event_name == 'pull_request' && 'config-server-pr' || 'config-server' }}
bart-vmware marked this conversation as resolved.
Show resolved Hide resolved
REGISTRY: ${{ vars.DOCKER_REGISTRY }}

jobs:
build-push:
Expand All @@ -31,21 +31,14 @@ jobs:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }}
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }} -DirectoryName "config-server"

- name: Login to private container registry
if: ${{ github.event_name == 'pull_request' }}
- name: Login to container registry
bart-vmware marked this conversation as resolved.
Show resolved Hide resolved
uses: docker/login-action@v3
with:
registry: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Login to Docker Hub
bart-vmware marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push image
run: docker push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
15 changes: 4 additions & 11 deletions .github/workflows/build_eureka_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ permissions:
contents: 'read'

env:
IMAGE_NAME: eureka-server
REGISTRY: ${{ github.event_name == 'pull_request' && vars.DOCKER_REGISTRY || 'steeltoeoss' }}
IMAGE_NAME: ${{ github.event_name == 'pull_request' && 'eureka-server-pr' || 'eureka-server' }}
REGISTRY: ${{ vars.DOCKER_REGISTRY }}

jobs:
build-push:
Expand All @@ -31,21 +31,14 @@ jobs:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }}
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }} -DirectoryName "eureka-server"

- name: Login to private container registry
if: ${{ github.event_name == 'pull_request' }}
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push image
run: docker push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44 changes: 44 additions & 0 deletions .github/workflows/build_springboot_admin_server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Spring Boot Admin Server

on:
pull_request:
branches:
- main
paths:
- 'spring-boot-admin/**'
push:
branches:
- main
paths:
- 'spring-boot-admin/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: 'read'

env:
IMAGE_NAME: ${{ github.event_name == 'pull_request' && 'spring-boot-admin-pr' || 'spring-boot-admin' }}
REGISTRY: ${{ vars.DOCKER_REGISTRY }}

jobs:
build-push:
name: Build and push image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }} -DirectoryName "spring-boot-admin"

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"

- name: Push image
run: docker push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37 changes: 15 additions & 22 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

.PARAMETER Registry
Set the container registry. Defaults to dockerhub under steeltoeoss.

.PARAMETER DirectoryName
Name of directory holding files that define the image. Defaults to the same value used for "Name".
#>

# -----------------------------------------------------------------------------
Expand All @@ -45,7 +48,8 @@ param (
[Switch] $List,
[String] $Name,
[String] $Tag,
[String] $Registry
[String] $Registry,
bart-vmware marked this conversation as resolved.
Show resolved Hide resolved
[String] $DirectoryName
)

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -85,13 +89,16 @@ if (!$Name)
throw "Name not specified; run with -Help for help"
}

$ImageDirectory = Join-Path $ImagesDirectory $Name
if (!(Test-Path $ImageDirectory))
if (!$DirectoryName)
{
throw "Unknown image $Name; run with -List to list available images"
$DirectoryName = $Name
}

$Name = Split-Path -Leaf $ImageDirectory # this removes stuff like ".\" prefix
$ImageDirectory = Join-Path $ImagesDirectory $DirectoryName
if (!(Test-Path $ImageDirectory))
{
throw "Unknown image $DirectoryName; run with -List to list available images"
}

if (!(Get-Command "docker" -ErrorAction SilentlyContinue))
{
Expand All @@ -101,7 +108,7 @@ if (!(Get-Command "docker" -ErrorAction SilentlyContinue))
$Dockerfile = Join-Path $ImageDirectory Dockerfile
if (!(Test-Path $Dockerfile))
{
throw "No Dockerfile for $Name (expected $Dockerfile)"
throw "No Dockerfile for $DirectoryName (expected $Dockerfile)"
}

if (!$Tag)
Expand All @@ -116,25 +123,11 @@ if (!$Tag)
{
$Tag += "-$Revision"
}
$Tag += " $(Get-Content $ImageDirectory/metadata/ADDITIONAL_TAGS | ForEach { $_.replace("$Name","$DockerOrg/$Name") })"
$Tag += " $(Get-Content $ImageDirectory/metadata/ADDITIONAL_TAGS | ForEach-Object { $_.replace("$DirectoryName","$DockerOrg/$Name") })"
}
else
{
$DockerArch = "amd64"
$DockerOs = "linux"
$Tag = "-t $DockerOrg/$Name-$DockerArch-$DockerOS"
$VersionMatcher = Select-String -Path $Dockerfile -Pattern '^ENV\s+IMAGE_VERSION\s*=?\s*(.+)$'
if ($VersionMatcher)
{
$Version = $VersionMatcher.Matches.Groups[1]
$Tag += ":$Version"
$RevisionMatcher = Select-String -Path $Dockerfile -Pattern '^ENV\s+IMAGE_REVISION\s*=?\s*(.+)$'
if ($RevisionMatcher)
{
$Revision = $RevisionMatcher.Matches.Groups[1]
$Tag += "-$Revision"
}
}
throw "No metadata found for $DirectoryName"
}
}

Expand Down
22 changes: 11 additions & 11 deletions config-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# Spring Config Server Build
# -----------------------------------------------------------------------------

FROM eclipse-temurin:21-alpine as build
FROM eclipse-temurin:21-alpine AS build
WORKDIR /scratch
RUN apk add httpie && apk add patch
RUN http https://start.spring.io/starter.zip \
type==gradle-project \
platformVersion==3.2.4 \
jvmVersion==21 \
groupId==io.steeltoe.docker \
artifactId==configserver \
applicationName==ConfigServer \
language==java \
dependencies==cloud-config-server,actuator,cloud-eureka \
RUN apk update && apk add ca-certificates && apk add curl && apk add patch
RUN curl --get https://start.spring.io/starter.zip \
-d "type=gradle-project" \
-d "platformVersion=3.3.4" \
-d "jvmVersion=21" \
-d "groupId=io.steeltoe.docker" \
-d "artifactId=configserver" \
-d "applicationName=ConfigServer" \
-d "language=java" \
-d "dependencies=cloud-config-server,actuator,cloud-eureka" \
--output configserver.zip
RUN mkdir configserver && unzip -d configserver configserver.zip
COPY metadata metadata
Expand Down
2 changes: 1 addition & 1 deletion config-server/metadata/IMAGE_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1
4.1.3
8 changes: 6 additions & 2 deletions config-server/patches/version.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
--- configserver/build.gradle 2024-02-21 09:39:40.000000000 -0600
+++ configserver/build.gradle 2024-02-21 11:03:17.615054116 -0600
@@ -5,7 +5,7 @@
@@ -5,11 +5,11 @@
}

group = 'io.steeltoe.docker'
-version = '0.0.1-SNAPSHOT'
+version = '<VERSION>'

java {
sourceCompatibility = '17'
toolchain {
- languageVersion = JavaLanguageVersion.of(17)
+ languageVersion = JavaLanguageVersion.of(21)
}
}
22 changes: 11 additions & 11 deletions eureka-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# Netflix Eureka Server Build
# -----------------------------------------------------------------------------

FROM eclipse-temurin:21-alpine as build
FROM eclipse-temurin:21-alpine AS build
WORKDIR /scratch
RUN apk add httpie && apk add patch
RUN http https://start.spring.io/starter.zip \
type==gradle-project \
platformVersion==3.2.4 \
jvmVersion==21 \
groupId==io.steeltoe.docker \
artifactId==eurekaserver \
applicationName==EurekaServer \
language==java \
dependencies==cloud-eureka-server,actuator \
RUN apk update && apk add ca-certificates && apk add curl && apk add patch
RUN curl --get https://start.spring.io/starter.zip \
-d "type=gradle-project" \
-d "platformVersion=3.3.4" \
-d "jvmVersion=21" \
-d "groupId=io.steeltoe.docker" \
-d "artifactId=eurekaserver" \
-d "applicationName=EurekaServer" \
-d "language=java" \
-d "dependencies=cloud-eureka-server,actuator" \
--output eurekaserver.zip
RUN mkdir eurekaserver && unzip -d eurekaserver eurekaserver.zip
COPY metadata metadata
Expand Down
2 changes: 1 addition & 1 deletion eureka-server/metadata/IMAGE_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1
4.1.3
8 changes: 6 additions & 2 deletions eureka-server/patches/version.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
--- eurekaserver/build.gradle 2024-02-21 15:44:45.075409600 -0600
+++ eurekaserver/build.gradle 2024-02-21 15:43:09.000000000 -0600
@@ -5,7 +5,7 @@
@@ -5,11 +5,11 @@
}

group = 'io.steeltoe.docker'
-version = '0.0.1-SNAPSHOT'
+version = '<VERSION>'

java {
sourceCompatibility = '17'
toolchain {
- languageVersion = JavaLanguageVersion.of(17)
+ languageVersion = JavaLanguageVersion.of(21)
}
}
43 changes: 31 additions & 12 deletions spring-boot-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
# -----------------------------------------------------------------------------
# Spring Boot Admin Server build
# Spring Boot Admin Server Build
# -----------------------------------------------------------------------------

FROM bellsoft/liberica-openjdk-alpine:8u252 as build
ENV IMAGE_VERSION 2.2.3
ENV GRADLE_OPTS -Dorg.gradle.daemon=false
FROM eclipse-temurin:21-alpine AS build
WORKDIR /scratch
COPY files .
RUN ./gradlew build
RUN ln -s build/libs/springbootadmin-${IMAGE_VERSION}.jar springbootadmin.jar
RUN apk update && apk add ca-certificates && apk add curl && apk add patch
RUN curl --get https://start.spring.io/starter.zip \
-d "type=gradle-project" \
-d "platformVersion=3.3.4" \
-d "jvmVersion=21" \
-d "groupId=io.steeltoe.docker" \
-d "artifactId=springbootadmin" \
-d "applicationName=SpringBootAdmin" \
-d "language=java" \
-d "dependencies=codecentric-spring-boot-admin-server" \
--output springbootadmin.zip
RUN mkdir springbootadmin && unzip -d springbootadmin springbootadmin.zip
COPY metadata metadata
COPY patches patches
RUN sed -i "s/<VERSION>/$(cat metadata/IMAGE_VERSION)/g" patches/version.patch
RUN for patch in patches/*.patch; do \
echo "applying patch $(basename $patch)"; \
cd springbootadmin; \
patch -p1 < ../$patch; \
cd ..; \
done
RUN springbootadmin/gradlew bootJar --project-dir springbootadmin --no-daemon
RUN mkdir output && \
cp "springbootadmin/build/libs/springbootadmin-$(cat metadata/IMAGE_VERSION).jar" output/springbootadmin.jar

# -----------------------------------------------------------------------------
# Spring Boot Admin Server image
# Spring Boot Admin Server Linux Image
# -----------------------------------------------------------------------------

FROM bellsoft/liberica-openjre-alpine:8u252
WORKDIR /spring-boot-admin
COPY --from=build /scratch .
EXPOSE 8080
FROM eclipse-temurin:21-alpine
bart-vmware marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /springbootadmin
COPY --from=build /scratch/output .
EXPOSE 9090
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "springbootadmin.jar"]
4 changes: 2 additions & 2 deletions spring-boot-admin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
:!toc-title:
:linkattrs:

SteeltoeOSS https://github.com/codecentric/spring-boot-admin docker image.
Image for SteeltoeOSS local development with https://github.com/codecentric/spring-boot-admin.
bart-vmware marked this conversation as resolved.
Show resolved Hide resolved

== Running

----
$ docker run --publish 8080:8080 steeltoeoss/spring-boot-admin
$ docker run --publish 9090:9090 steeltoeoss/spring-boot-admin
----
32 changes: 0 additions & 32 deletions spring-boot-admin/files/.gitignore

This file was deleted.

Loading