generated from NethServer/ns8-kickstart
-
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.
- Loading branch information
1 parent
f0967ca
commit aa2bd6f
Showing
3 changed files
with
64 additions
and
2 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
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,53 @@ | ||
#!/bin/bash | ||
|
||
# Terminate on error | ||
set -e | ||
|
||
# Prepare variables for later use | ||
images=() | ||
# The image will be pushed to GitHub container registry | ||
repobase="${REPOBASE:-ghcr.io/nethserver}" | ||
webssh_version=$1 | ||
|
||
# Create a new empty container for webssh | ||
echo "Build webssh container" # from https://github.com/huashengdun/webssh | ||
mkdir -p webssh_tmp/build | ||
pushd webssh_tmp | ||
wget https://github.com/huashengdun/webssh/archive/refs/tags/v${webssh_version}.tar.gz -O webssh.tar.gz | ||
tar xvzf webssh.tar.gz -C build --strip-components=1 | ||
pushd build | ||
webssh=$(buildah from docker.io/python:3-alpine) | ||
buildah add "${webssh}" . /code | ||
buildah run \ | ||
--workingdir '/code' \ | ||
${webssh} \ | ||
sh -c "apk add --no-cache libc-dev libffi-dev gcc && \ | ||
pip install -r requirements.txt --no-cache-dir && \ | ||
apk del gcc libc-dev libffi-dev && \ | ||
addgroup webssh && \ | ||
adduser -Ss /bin/false -g webssh webssh && \ | ||
chown -R webssh:webssh /code | ||
" | ||
popd | ||
popd | ||
rm -rf webssh_tmp | ||
# Commit the image | ||
buildah add "${webssh}" entrypoint.sh /entrypoint.sh | ||
buildah config --workingdir '/code' --entrypoint='["/entrypoint.sh"]' --cmd='["python", "run.py"]' "${webssh}" | ||
buildah commit "${webssh}" "${repobase}/webssh" | ||
|
||
# Append the image URL to the images array | ||
images+=("${repobase}/webssh") | ||
|
||
# | ||
# Setup CI when pushing to Github. | ||
# Warning! docker::// protocol expects lowercase letters (,,) | ||
if [[ -n "${CI}" ]]; then | ||
# Set output value for Github Actions | ||
printf "::set-output name=images::%s\n" "${images[*],,}" | ||
else | ||
# Just print info for manual push | ||
printf "Publish the images with:\n\n" | ||
for image in "${images[@],,}"; do printf " buildah push %s docker://%s:%s\n" "${image}" "${image}" "${IMAGETAG:-latest}" ; done | ||
printf "\n" | ||
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,3 @@ | ||
#!/bin/sh | ||
|
||
exec "$@" |