-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: refactor image regeneration (#2483)
This PR optimizes the scripts/workflow for regenerating the images. It also uses mint to minify the images.
- Loading branch information
1 parent
e06039f
commit 1ed75c9
Showing
6 changed files
with
105 additions
and
60 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 |
---|---|---|
@@ -1,22 +1,5 @@ | ||
ARG BASE=ghcr.io/sbb-design-systems/sbb-angular/showcase:latest | ||
FROM $BASE as base | ||
|
||
# For version 11 + 12 | ||
FROM nginxinc/nginx-unprivileged:stable as initless | ||
|
||
# Copy config from base image | ||
COPY --from=base /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf | ||
# Copy showcase from base image | ||
COPY --from=base /usr/share/nginx/html /usr/share/nginx/html | ||
|
||
# For versions 13+ | ||
FROM nginxinc/nginx-unprivileged:stable as init | ||
FROM nginxinc/nginx-unprivileged:stable | ||
|
||
# Copy config from base image | ||
COPY --from=base /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf | ||
# Copy showcase from base image | ||
COPY --from=base /usr/share/nginx/html /usr/share/nginx/html | ||
# Copy ngssc from base image if it exists | ||
COPY --from=base /usr/sbin/ngssc /usr/sbin/ngssc | ||
# Copy ngssc.sh from base image if it exists | ||
COPY --from=base /docker-entrypoint.d/ngssc.sh /docker-entrypoint.d/ngssc.sh | ||
COPY default.conf /etc/nginx/conf.d/default.conf | ||
COPY html /usr/share/nginx/html |
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,11 @@ | ||
# For versions 13+ | ||
FROM nginxinc/nginx-unprivileged:stable | ||
|
||
COPY default.conf /etc/nginx/conf.d/default.conf | ||
COPY html /usr/share/nginx/html | ||
USER root | ||
COPY ngssc /usr/sbin/ngssc | ||
RUN chmod +x /usr/sbin/ngssc | ||
COPY ngssc.sh /docker-entrypoint.d/ngssc.sh | ||
RUN chmod +x /docker-entrypoint.d/ngssc.sh | ||
USER $UID |
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
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,19 @@ | ||
set -e | ||
|
||
if [ -z "${START_VERSION}" ]; then | ||
echo "Missing START_VERSION variable" | ||
exit 1 | ||
fi | ||
|
||
majorVersion=$START_VERSION | ||
versions=() | ||
|
||
while : ; do | ||
version=$(git tag --sort=v:refname -l "$majorVersion.*.*" | tail -1) | ||
[[ "$version" != "" ]] || break | ||
versions+=("$version") | ||
majorVersion=$((majorVersion+1)) | ||
done | ||
|
||
printf -v joined '"%s", ' "${versions[@]}" | ||
echo "versions=[${joined::-2}]" |
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,47 @@ | ||
set -e | ||
|
||
if [ -z "${IMAGE_REPO}" ]; then | ||
echo "Missing IMAGE_REPO variable" | ||
exit 1 | ||
elif [ -z "${VERSION}" ]; then | ||
echo "Missing VERSION variable" | ||
exit 1 | ||
fi | ||
|
||
image="$IMAGE_REPO:$VERSION" | ||
majorVersion="${VERSION%.*.*}" | ||
target="" | ||
echo "" | ||
echo "Regenerating $image" | ||
echo "" | ||
|
||
mkdir -p "$PWD/dist" | ||
|
||
docker create --name dummy $image | ||
if [[ $majorVersion > 12 ]]; then | ||
target=".ngssc" | ||
docker cp dummy:/usr/sbin/ngssc "$PWD/dist/ngssc" | ||
docker cp dummy:/docker-entrypoint.d/ngssc.sh "$PWD/dist/ngssc.sh" | ||
fi | ||
|
||
docker cp dummy:/etc/nginx/conf.d/default.conf "$PWD/dist/default.conf" | ||
docker cp dummy:/usr/share/nginx/html "$PWD/dist/html/" | ||
|
||
docker rm -f dummy | ||
|
||
docker build \ | ||
--tag tmp-fat \ | ||
--file ".github/Dockerfile.regenerate$target" \ | ||
"$PWD/dist" | ||
|
||
mint slim \ | ||
--target tmp-fat \ | ||
--tag tmp \ | ||
--preserve-path /usr/share/nginx/html | ||
|
||
docker tag tmp "$image" | ||
docker push "$image" | ||
|
||
echo "" | ||
echo "Finished regenerating $image" | ||
echo "" |