forked from keycloak/keycloak-containers
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AUTH-544] Keycloak containers (16.1.1-patch)
- Loading branch information
1 parent
1999e68
commit c349b0b
Showing
8 changed files
with
241 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
dist: xenial | ||
sudo: required | ||
|
||
services: | ||
- docker | ||
|
||
cache: | ||
directories: | ||
- $HOME/.m2 | ||
- $HOME/.npm | ||
|
||
before_cache: | ||
- rm -rf $HOME/.m2/repository/org/keycloak | ||
|
||
env: | ||
global: | ||
- MAVEN_OPTS="-Xms512m -Xmx1536m" | ||
- THEME_VERSION=0.3.2 | ||
|
||
branches: | ||
only: | ||
- master | ||
- develop | ||
- /AUTH-.*/ | ||
- /OPSEXP-.*/ | ||
|
||
stages: | ||
- name: "Build Dev" | ||
if: branch = develop | ||
- name: Build | ||
if: (branch = master AND type != pull_request) OR branch =~ /AUTH-.*/ OR branch =~ /OPSEXP-.*/ | ||
- name: Release | ||
if: commit_message =~ /\[release\]/ | ||
|
||
before_script: | ||
- echo "${QUAY_PASSWORD}" | docker login quay.io --username ${QUAY_USERNAME} --password-stdin | ||
|
||
jobs: | ||
include: | ||
- stage: "Build Dev" | ||
name: "Build from develop branch and Push images" | ||
language: java | ||
jdk: openjdk11 | ||
script: | | ||
cd server | ||
IDS_VERSION=$(cat build.properties | grep IDENTITY_VERSION | awk -F "=" '{print $2}') | ||
DEV_VERSION="develop-${TRAVIS_BUILD_NUMBER}" | ||
echo "Changing the image tag from '${IDS_VERSION}' to '${DEV_VERSION}' ..." | ||
sed -i "s/$IDS_VERSION/$DEV_VERSION/g" build.properties | ||
travis_fold start build_keycloak_server | ||
make build_keycloak build_image push_private cleanup | ||
travis_fold end build_keycloak_server | ||
- stage: "Build" | ||
name: "Build from distribution zip and Push images" | ||
language: minimal | ||
script: | | ||
cd server | ||
if [[ "${TRAVIS_COMMIT_MESSAGE}" = *"[release]"* ]]; then | ||
make download_keycloak build_image push_private cleanup | ||
else | ||
IDS_VERSION=$(cat build.properties | grep IDENTITY_VERSION | awk -F "=" '{print $2}') | ||
SUFFIX=$(echo ${TRAVIS_BRANCH} | cut -c1-20 | tr /_ - | tr -d [:punct:] | awk '{print tolower($0)}') | ||
ALPHA_BUILD_VERSION="${SUFFIX}-${TRAVIS_BUILD_NUMBER}" | ||
echo "Changing the image tag from '${IDS_VERSION}' to '${ALPHA_BUILD_VERSION}' as this is not a release commit..." | ||
sed -i "s/$IDS_VERSION/$ALPHA_BUILD_VERSION/g" build.properties | ||
make download_keycloak build_image push_private cleanup | ||
fi | ||
- stage: release | ||
name: "Release keycloak-containers in GitHub" | ||
script: | ||
- git config --local user.email "${GIT_EMAIL}" | ||
- git config --local user.name "${GIT_USERNAME}" | ||
- cd server && ./release.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
include build.properties | ||
export $(shell sed 's/=.*//' build.properties) | ||
|
||
IMAGE_NAME :=alfresco/alfresco-identity-service:$(IDENTITY_VERSION) | ||
IMAGE_NAME_WITH_BASE_OS :=$(IMAGE_NAME)-java-11-openjdk-ubi8-minimal | ||
IMAGE_NAME_WITH_BASE_OS_AND_SHA :=$(IMAGE_NAME_WITH_BASE_OS)-$(shell git rev-parse HEAD | cut -c1-12) | ||
export IMAGE_NAME | ||
export IMAGE_NAME_WITH_BASE_OS | ||
export IMAGE_NAME_WITH_BASE_OS_AND_SHA | ||
|
||
# Alfresco keycloak variables | ||
KEYCLOAK_DIST :=https://github.com/Alfresco/keycloak/releases/download/$(KEYCLOAK_VERSION)/keycloak-$(KEYCLOAK_VERSION).zip | ||
# Dev properties | ||
GIT_REPO :=Alfresco/keycloak | ||
# 'master' will be used if not set | ||
GIT_BRANCH := | ||
THEME_VERSION ?=0.3.2 | ||
|
||
|
||
build: download_keycloak build_image push_private cleanup | ||
|
||
download_keycloak: | ||
@./build-keycloak-locally.sh keycloak_dist=$(KEYCLOAK_DIST) | ||
|
||
# Dev time rule | ||
build_keycloak: | ||
@./build-keycloak-locally.sh git_repo=$(GIT_REPO) git_branch=$(GIT_BRANCH) theme_version=$(THEME_VERSION) || (echo "Couldn't build keycloak. Make sure you are building with the correct Java version."; rm -rf temp; exit 1) | ||
|
||
build_image: | ||
@./build-image.sh | ||
|
||
push_private: | ||
@echo "Push private docker image..." | ||
@docker push quay.io/$(IMAGE_NAME) | ||
@docker push quay.io/$(IMAGE_NAME_WITH_BASE_OS) | ||
@docker push quay.io/$(IMAGE_NAME_WITH_BASE_OS_AND_SHA) | ||
|
||
tag_push_public: | ||
@echo "Tag and push public image..." | ||
@docker tag quay.io/$(IMAGE_NAME_WITH_BASE_OS_AND_SHA) $(IMAGE_NAME) && docker push $(IMAGE_NAME) | ||
@docker tag quay.io/$(IMAGE_NAME_WITH_BASE_OS_AND_SHA) $(IMAGE_NAME_WITH_BASE_OS) && docker push $(IMAGE_NAME_WITH_BASE_OS) | ||
@docker tag quay.io/$(IMAGE_NAME_WITH_BASE_OS_AND_SHA) $(IMAGE_NAME_WITH_BASE_OS_AND_SHA) && docker push $(IMAGE_NAME_WITH_BASE_OS_AND_SHA) | ||
|
||
cleanup: | ||
@rm -rf temp | ||
|
||
run: | ||
@docker run -e DB_VENDOR=h2 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin --name alfresco-ids -p 8080:8080 --rm quay.io/$(IMAGE_NAME) | ||
|
||
stop: | ||
@docker stop alfresco-ids | ||
|
||
sh: | ||
@docker exec -it $$(docker ps -aq --filter name=alfresco-ids) bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash -e | ||
|
||
EXPIRE_AFTER="${EXPIRE_AFTER:-2w}" | ||
|
||
EXPIRES_AFTER_LABEL="" | ||
if [ ! -z "$BRANCH_NAME" -a "$BRANCH_NAME" != "master" -a "$BRANCH_NAME" != "develop" ]; then | ||
# Add expiration label so it can be deleted by quay automatically | ||
EXPIRES_AFTER_LABEL="--label quay.expires-after=$EXPIRE_AFTER" | ||
fi | ||
|
||
if [ -z "$EXPIRES_AFTER_LABEL" ]; then | ||
echo "Building image with three tags: '$IMAGE_NAME', '$IMAGE_NAME_WITH_BASE_OS', and '$IMAGE_NAME_WITH_BASE_OS_AND_SHA' ..." | ||
else | ||
echo "Building image with three tags: '$IMAGE_NAME', '$IMAGE_NAME_WITH_BASE_OS', and '$IMAGE_NAME_WITH_BASE_OS_AND_SHA' with label: '$EXPIRES_AFTER_LABEL'..." | ||
fi | ||
|
||
docker build --force-rm=true --no-cache=true --build-arg KEYCLOAK_VERSION=$KEYCLOAK_VERSION -t quay.io/$IMAGE_NAME_WITH_BASE_OS_AND_SHA -t quay.io/$IMAGE_NAME -t quay.io/$IMAGE_NAME_WITH_BASE_OS -f Dockerfile . $EXPIRES_AFTER_LABEL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash -e | ||
|
||
### Available environment variables: | ||
# - GIT_REPO | ||
# - GIT_BRANCH ('master' will be used if not set) | ||
# - THEME_VERSION | ||
# or | ||
# - KEYCLOAK_DIST | ||
# | ||
### Available parameters: | ||
# - git_repo | ||
# - git_branch ('master' will be used if not set) | ||
# - theme_version | ||
# or | ||
# - keycloak_dist | ||
# | ||
# Example: | ||
# sh build-keycloak-locally.sh git_repo=Alfresco/myrepo git_branch=test-branch theme_version=0.3.2 | ||
# | ||
### Note: ENV variables will take precedence over the passed parameters. | ||
# | ||
|
||
ARGS=$@ | ||
for arg in $ARGS; do | ||
eval "$arg" | ||
done | ||
|
||
mkdir -p temp | ||
cd temp | ||
|
||
GIT_REPO="${GIT_REPO:-$git_repo}" | ||
GIT_BRANCH="${GIT_BRANCH:-$git_branch}" | ||
KEYCLOAK_DIST="${KEYCLOAK_DIST:-$keycloak_dist}" | ||
|
||
if [ "$GIT_REPO" != "" ]; then | ||
if [ "$GIT_BRANCH" == "" ]; then | ||
GIT_BRANCH="master" | ||
fi | ||
|
||
THEME_VERSION="${THEME_VERSION:-$theme_version}" | ||
export THEME_VERSION="$THEME_VERSION" | ||
|
||
# Clone repository | ||
git clone --depth 1 https://github.com/$GIT_REPO.git -b $GIT_BRANCH keycloak-source | ||
|
||
# Build | ||
cd keycloak-source | ||
|
||
MASTER_HEAD=$(git log -n1 --format="%H") | ||
echo "Build Keycloak from: $GIT_REPO/$GIT_BRANCH/commit/$MASTER_HEAD" | ||
|
||
mvn -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install | ||
# Add Alfresco theme | ||
./add-alfresco-theme.sh | ||
|
||
cd .. | ||
unzip -oq keycloak-source/distribution/server-dist/target/keycloak-*.zip | ||
rm -rf keycloak-source | ||
mv keycloak-* keycloak | ||
|
||
else | ||
echo "Download Keycloak from: $KEYCLOAK_DIST" | ||
if [ -z "$KEYCLOAK_DIST" ]; then | ||
echo "KEYCLOAK_DIST variable is not set." | ||
exit 1 | ||
fi | ||
|
||
curl -sSLO $KEYCLOAK_DIST | ||
unzip -oq keycloak-*.zip | ||
rm keycloak-*.zip | ||
mv keycloak-* keycloak | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
KEYCLOAK_VERSION=16.1.1-patch | ||
IDENTITY_VERSION=1.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash -e | ||
|
||
declare -r currentDir="$(dirname "${BASH_SOURCE[0]}")" | ||
source "${currentDir}/build.properties" | ||
|
||
TAG=${KEYCLOAK_VERSION} | ||
if [ -z "$TAG" ]; then | ||
echo "KEYCLOAK_VERSION variable is not set." | ||
exit 1 | ||
fi | ||
|
||
CURRENT_BRANCH=$(git branch | grep '*' | cut -d' ' -f 2) | ||
|
||
echo "Tag '$CURRENT_BRANCH' branch as '$TAG'" | ||
git tag -f ${TAG} -m "[release-script][skip ci]" | ||
git remote rm origin | ||
echo "Push $TAG tag." | ||
GITHUB_REPO=https://$GITHUB_TOKEN:[email protected]/Alfresco/keycloak-containers.git | ||
git remote add origin $GITHUB_REPO | ||
git push origin --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters