Skip to content

Commit

Permalink
Build special tags during PR instead of different image name, revert …
Browse files Browse the repository at this point in the history
…-DirectoryName addition, update readme files, use alpine for config server running image
  • Loading branch information
TimHess committed Sep 27, 2024
1 parent fd082e0 commit 495f6c4
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 63 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build_config_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ concurrency:
cancel-in-progress: true

permissions:
contents: 'read'
contents: read

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

jobs:
Expand All @@ -31,14 +31,17 @@ jobs:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }} -DirectoryName "config-server"
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
shell: pwsh
env:
TAG: ${{ github.event_name == 'pull_request' && format('-t {0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) }}

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
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 }}
15 changes: 9 additions & 6 deletions .github/workflows/build_eureka_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ concurrency:
cancel-in-progress: true

permissions:
contents: 'read'
contents: read

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

jobs:
Expand All @@ -31,14 +31,17 @@ jobs:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }} -DirectoryName "eureka-server"
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
shell: pwsh
env:
TAG: ${{ github.event_name == 'pull_request' && format('-t {0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) }}

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
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 }}
15 changes: 9 additions & 6 deletions .github/workflows/build_springboot_admin_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ concurrency:
cancel-in-progress: true

permissions:
contents: 'read'
contents: read

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

jobs:
Expand All @@ -31,14 +31,17 @@ jobs:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name ${{ env.IMAGE_NAME }} -Registry ${{ env.REGISTRY }} -DirectoryName "spring-boot-admin"
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
shell: pwsh
env:
TAG: ${{ github.event_name == 'pull_request' && format('-t {0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) }}

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
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 }}
24 changes: 10 additions & 14 deletions .github/workflows/build_uaa_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ concurrency:
cancel-in-progress: true

permissions:
contents: 'read'
contents: read

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

jobs:
build-push:
Expand All @@ -31,21 +31,17 @@ 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 }}' -Tag '${{ env.TAG }}'
shell: pwsh
env:
TAG: ${{ github.event_name == 'pull_request' && format('-t {0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) }}

- 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 }}
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 }}
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:!toc-title:
:linkattrs:

GitHub repo for SteeltoeOSS Docker images.
GitHub repo for server images to use for local development with SteeltoeOSS.

== Building

Expand All @@ -28,16 +28,16 @@ See the link:https://github.com/SteeltoeOSS/Samples/blob/main/CommonTasks.md/[do
|===
|Name |Description

|link:config-server/[steeltoeoss/config-server]
|link:config-server/[steeltoe.azurecr.io/config-server]
| Spring Cloud Config Server

|link:eureka-server/[steeltoeoss/eureka-server]
|link:eureka-server/[steeltoe.azurecr.io/eureka-server]
| Netflix Eureka Server

|link:spring-boot-admin/[steeltoeoss/spring-boot-admin]
|link:spring-boot-admin/[steeltoe.azurecr.io/spring-boot-admin]
| Spring Boot Admin

|link:uaa-server/[steeltoeoss/uaa-server]
|link:uaa-server/[steeltoe.azurecr.io/uaa-server]
| CloudFoundry UAA Server

|===
Expand Down
27 changes: 11 additions & 16 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
.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 @@ -48,8 +45,7 @@ param (
[Switch] $List,
[String] $Name,
[String] $Tag,
[String] $Registry,
[String] $DirectoryName
[String] $Registry
)

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

if (!$DirectoryName)
{
$DirectoryName = $Name
}

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

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

if (!$Tag)
Expand All @@ -123,14 +114,18 @@ if (!$Tag)
{
$Tag += "-$Revision"
}
$Tag += " $(Get-Content $ImageDirectory/metadata/ADDITIONAL_TAGS | ForEach-Object { $_.replace("$DirectoryName","$DockerOrg/$Name") })"
$Tag += " $(Get-Content $ImageDirectory/metadata/ADDITIONAL_TAGS | ForEach-Object { $_.replace("$Name","$DockerOrg/$Name") })"
}
else
{
throw "No metadata found for $DirectoryName"
throw "No metadata found for $Name"
}
}
else
{
Write-Host "Tag value set by script parameter:" $Tag
}

$docker_command = "docker build $Tag $ImageDirectory"
Write-host $docker_command
Write-Host $docker_command
Invoke-Expression $docker_command
2 changes: 1 addition & 1 deletion config-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN mkdir output && \
# Spring Config Server Linux Image
# -----------------------------------------------------------------------------

FROM eclipse-temurin:21
FROM eclipse-temurin:21-alpine
WORKDIR /config-server
COPY --from=build /scratch/output .
EXPOSE 8888
Expand Down
10 changes: 5 additions & 5 deletions config-server/README.adoc
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
= steeltoeoss/config-server
= steeltoe.azurecr.io/config-server
:toc: preamble
:toclevels: 1
:!toc-title:
:linkattrs:

SteeltoeOSS https://cloud.spring.io/spring-cloud-config/[Spring Cloud Config Server] docker image.
Image for SteeltoeOSS local development with https://cloud.spring.io/spring-cloud-config/[Spring Cloud Config Server].

== Running

.Default Configuration
----
$ docker run --publish 8888:8888 steeltoeoss/config-server
$ docker run --publish 8888:8888 steeltoe.azurecr.io/config-server
----

.Custom Git Repo Configuration
----
$ docker run --publish 8888:8888 steeltoeoss/config-server \
$ docker run --publish 8888:8888 steeltoe.azurecr.io/config-server \
--spring.cloud.config.server.git.uri=https://github.com/myorg/myrepo.git
----

.Local File System Configuration
----
$ docker run --publish 8888:8888 --volume /path/to/my/config:/config steeltoeoss/config-server \
$ docker run --publish 8888:8888 --volume /path/to/my/config:/config steeltoe.azurecr.io/config-server \
--spring.profiles.active=native \
--spring.cloud.config.server.native.searchLocations=file:///config
----
Expand Down
6 changes: 3 additions & 3 deletions eureka-server/README.adoc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
= steeltoeoss/eureka-server
= steeltoe.azurecr.io/eureka-server
:toc: preamble
:toclevels: 1
:!toc-title:
:linkattrs:

SteeltoeOSS https://cloud.spring.io/spring-cloud-netflix/[Spring Cloud Eureka Server] docker image.
Image for SteeltoeOSS local development with https://cloud.spring.io/spring-cloud-netflix/[Spring Cloud Eureka Server].

== Running

----
$ docker run --publish 8761:8761 steeltoeoss/eureka-server
$ docker run --publish 8761:8761 steeltoe.azurecr.io/eureka-server
----

== Resources
Expand Down
2 changes: 1 addition & 1 deletion uaa-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ These instructions will help you build and deploy a custom image to use as an id
1. (Operator task) Create an [identity zone](https://docs.vmware.com/en/VMware-Tanzu-Application-Service/6.0/tas-for-vms/uaa-concepts.html#identity-zones-0)
1. Change the `redirect-uri` entry for `ssotile` in [uaa.yml](uaa.yml#132) to match your identity zone.
1. (OPTIONAL) Customize the name of the image you're about to build by renaming the `uaa-server` directory
1. `.\build.ps1 .\uaa-server`.
1. `.\build.ps1 uaa-server`.
1. Push the image to an image repository accessible from your Cloud Foundry environment.
1. Deploy the image with a command similar to this:
* `cf push steeltoe-uaa --docker-image steeltoe.azurecr.io/uaa-server:77.10`
Expand Down

0 comments on commit 495f6c4

Please sign in to comment.