Skip to content

Commit

Permalink
adding tftp branch for build
Browse files Browse the repository at this point in the history
  • Loading branch information
thelamer committed Dec 11, 2019
1 parent 3ce31be commit 720821d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 66 deletions.
31 changes: 23 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,41 @@ FROM lsiobase/alpine:3.10
# set version label
ARG BUILD_DATE
ARG VERSION
ARG NETBOOTXYZ_RELEASE
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thelamer"

# build args
ARG DOWNURL="https://boot.netboot.xyz/ipxe"

RUN \
echo "**** install build packages ****" && \
apk add --no-cache --virtual=build-dependencies \
curl \
jq && \
echo "**** install runtime packages ****" && \
apk add --no-cache \
tftp-hpa && \
echo "**** download netboot payloads ****" && \
wget -O \
/config/netboot.xyz.kpxe \
if [ -z ${NETBOOTXYZ_RELEASE+x} ]; then \
NETBOOTXYZ_RELEASE=$(curl -sX GET "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
DOWNURL="https://github.com/netbootxyz/netboot.xyz/releases/download/${NETBOOTXYZ_RELEASE}" && \
curl -o \
/config/netboot.xyz.kpxe -L \
${DOWNURL}/netboot.xyz.kpxe && \
wget -O \
/config/netboot.xyz.efi \
curl -o \
/config/netboot.xyz.efi -L \
${DOWNURL}/netboot.xyz.efi && \
curl -o \
/config/netboot.xyz-undionly.kpxe -L \
${DOWNURL}/netboot.xyz-undionly.kpxe && \
echo "**** Permissions ****" && \
chown -R abc:abc \
/config
/config && \
echo "**** cleanup ****" && \
apk del --purge \
build-dependencies && \
rm -rf \
/tmp/*

# add local files
COPY /root /
111 changes: 59 additions & 52 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pipeline {
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
CONTAINER_NAME = 'netbootxyz'
BUILD_VERSION_ARG = 'NETBOOTXYZ_SHA'
BUILD_VERSION_ARG = 'NETBOOTXYZ_RELEASE'
LS_USER = 'linuxserver'
LS_REPO = 'docker-netbootxyz'
DOCKERHUB_IMAGE = 'linuxserver/netbootxyz'
Expand All @@ -41,7 +41,7 @@ pipeline {
script{
env.EXIT_STATUS = ''
env.LS_RELEASE = sh(
script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':tftp 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
returnStdout: true).trim()
env.LS_RELEASE_NOTES = sh(
script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''',
Expand Down Expand Up @@ -98,16 +98,23 @@ pipeline {
/* ########################
External Release Tagging
######################## */
// If this is a custom command to determine version use that command
stage("Set tag custom bash"){
steps{
script{
env.EXT_RELEASE = sh(
script: ''' curl -sL https://boot.netboot.xyz/ipxe/netboot.xyz-sha256-checksums.txt | grep 'netboot.xyz.kpxe' | cut -c1-8 ''',
returnStdout: true).trim()
env.RELEASE_LINK = 'custom_command'
}
}
// If this is a stable github release use the latest endpoint from github to determine the ext tag
stage("Set ENV github_stable"){
steps{
script{
env.EXT_RELEASE = sh(
script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''',
returnStdout: true).trim()
}
}
}
// If this is a stable or devel github release generate the link for the build message
stage("Set ENV github_link"){
steps{
script{
env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE
}
}
}
// Sanitize the release tag and strip illegal docker or github characters
stage("Sanitize tag"){
Expand All @@ -119,10 +126,10 @@ pipeline {
}
}
}
// If this is a master build use live docker endpoints
// If this is a tftp build use live docker endpoints
stage("Set ENV live build"){
when {
branch "master"
branch "tftp"
environment name: 'CHANGE_ID', value: ''
}
steps {
Expand All @@ -143,7 +150,7 @@ pipeline {
// If this is a dev build use dev docker endpoints
stage("Set ENV dev build"){
when {
not {branch "master"}
not {branch "tftp"}
environment name: 'CHANGE_ID', value: ''
}
steps {
Expand Down Expand Up @@ -216,7 +223,7 @@ pipeline {
// Use helper containers to render templated files
stage('Update-Templates') {
when {
branch "master"
branch "tftp"
environment name: 'CHANGE_ID', value: ''
expression {
env.CONTAINER_NAME != null
Expand All @@ -227,15 +234,15 @@ pipeline {
set -e
TEMPDIR=$(mktemp -d)
docker pull linuxserver/jenkins-builder:latest
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=master -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=tftp -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest
CURRENTHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8)
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
NEWHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8)
if [[ "${CURRENTHASH}" != "${NEWHASH}" ]]; then
mkdir -p ${TEMPDIR}/repo
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
cd ${TEMPDIR}/repo/${LS_REPO}
git checkout -f master
git checkout -f tftp
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/
Expand Down Expand Up @@ -267,7 +274,7 @@ pipeline {
// Exit the build if the Templated files were just updated
stage('Template-exit') {
when {
branch "master"
branch "tftp"
environment name: 'CHANGE_ID', value: ''
environment name: 'FILES_UPDATED', value: 'true'
expression {
Expand Down Expand Up @@ -386,7 +393,7 @@ pipeline {
// Take the image we just built and dump package versions for comparison
stage('Update-packages') {
when {
branch "master"
branch "tftp"
environment name: 'CHANGE_ID', value: ''
environment name: 'EXIT_STATUS', value: ''
}
Expand Down Expand Up @@ -414,7 +421,7 @@ pipeline {
echo "Package tag sha from current packages in buit container is ${NEW_PACKAGE_TAG} comparing to old ${PACKAGE_TAG} from github"
if [ "${NEW_PACKAGE_TAG}" != "${PACKAGE_TAG}" ]; then
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/${LS_REPO}
git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f master
git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f tftp
cp ${TEMPDIR}/package_versions.txt ${TEMPDIR}/${LS_REPO}/
cd ${TEMPDIR}/${LS_REPO}/
wait
Expand All @@ -438,7 +445,7 @@ pipeline {
// Exit the build if the package file was just updated
stage('PACKAGE-exit') {
when {
branch "master"
branch "tftp"
environment name: 'CHANGE_ID', value: ''
environment name: 'PACKAGE_UPDATED', value: 'true'
environment name: 'EXIT_STATUS', value: ''
Expand All @@ -452,7 +459,7 @@ pipeline {
// Exit the build if this is just a package check and there are no changes to push
stage('PACKAGECHECK-exit') {
when {
branch "master"
branch "tftp"
environment name: 'CHANGE_ID', value: ''
environment name: 'PACKAGE_UPDATED', value: 'false'
environment name: 'EXIT_STATUS', value: ''
Expand Down Expand Up @@ -547,14 +554,14 @@ pipeline {
echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin
for PUSHIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do
docker tag ${IMAGE}:${META_TAG} ${PUSHIMAGE}:${META_TAG}
docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:latest
docker push ${PUSHIMAGE}:latest
docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:tftp
docker push ${PUSHIMAGE}:tftp
docker push ${PUSHIMAGE}:${META_TAG}
done
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "{GITLABIMAGE}" "${IMAGE}"; do
docker rmi \
${DELETEIMAGE}:${META_TAG} \
${DELETEIMAGE}:latest || :
${DELETEIMAGE}:tftp || :
done
'''
}
Expand Down Expand Up @@ -597,52 +604,52 @@ pipeline {
docker tag ${IMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG}
docker tag ${IMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG}
docker tag ${IMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-latest
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-latest
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-latest
docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-tftp
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-tftp
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-tftp
docker push ${MANIFESTIMAGE}:amd64-${META_TAG}
docker push ${MANIFESTIMAGE}:arm32v7-${META_TAG}
docker push ${MANIFESTIMAGE}:arm64v8-${META_TAG}
docker push ${MANIFESTIMAGE}:amd64-latest
docker push ${MANIFESTIMAGE}:arm32v7-latest
docker push ${MANIFESTIMAGE}:arm64v8-latest
docker manifest push --purge ${MANIFESTIMAGE}:latest || :
docker manifest create ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:arm64v8-latest
docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm32v7-latest --os linux --arch arm
docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm64v8-latest --os linux --arch arm64 --variant v8
docker push ${MANIFESTIMAGE}:amd64-tftp
docker push ${MANIFESTIMAGE}:arm32v7-tftp
docker push ${MANIFESTIMAGE}:arm64v8-tftp
docker manifest push --purge ${MANIFESTIMAGE}:tftp || :
docker manifest create ${MANIFESTIMAGE}:tftp ${MANIFESTIMAGE}:amd64-tftp ${MANIFESTIMAGE}:arm32v7-tftp ${MANIFESTIMAGE}:arm64v8-tftp
docker manifest annotate ${MANIFESTIMAGE}:tftp ${MANIFESTIMAGE}:arm32v7-tftp --os linux --arch arm
docker manifest annotate ${MANIFESTIMAGE}:tftp ${MANIFESTIMAGE}:arm64v8-tftp --os linux --arch arm64 --variant v8
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} || :
docker manifest create ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} --os linux --arch arm
docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8
docker manifest push --purge ${MANIFESTIMAGE}:latest
docker manifest push --purge ${MANIFESTIMAGE}:tftp
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG}
done
for LEGACYIMAGE in "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
docker tag ${IMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:amd64-${META_TAG}
docker tag ${IMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-${META_TAG}
docker tag ${IMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-${META_TAG}
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:latest
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:tftp
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:${META_TAG}
docker tag ${LEGACYIMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-latest
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-latest
docker tag ${LEGACYIMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-tftp
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-tftp
docker push ${LEGACYIMAGE}:amd64-${META_TAG}
docker push ${LEGACYIMAGE}:arm32v7-${META_TAG}
docker push ${LEGACYIMAGE}:arm64v8-${META_TAG}
docker push ${LEGACYIMAGE}:latest
docker push ${LEGACYIMAGE}:tftp
docker push ${LEGACYIMAGE}:${META_TAG}
docker push ${LEGACYIMAGE}:arm32v7-latest
docker push ${LEGACYIMAGE}:arm64v8-latest
docker push ${LEGACYIMAGE}:arm32v7-tftp
docker push ${LEGACYIMAGE}:arm64v8-tftp
done
'''
sh '''#! /bin/bash
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do
docker rmi \
${DELETEIMAGE}:amd64-${META_TAG} \
${DELETEIMAGE}:amd64-latest \
${DELETEIMAGE}:amd64-tftp \
${DELETEIMAGE}:arm32v7-${META_TAG} \
${DELETEIMAGE}:arm32v7-latest \
${DELETEIMAGE}:arm32v7-tftp \
${DELETEIMAGE}:arm64v8-${META_TAG} \
${DELETEIMAGE}:arm64v8-latest || :
${DELETEIMAGE}:arm64v8-tftp || :
done
docker rmi \
lsiodev/buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} \
Expand All @@ -654,7 +661,7 @@ pipeline {
// If this is a public release tag it in the LS Github
stage('Github-Tag-Push-Release') {
when {
branch "master"
branch "tftp"
expression {
env.LS_RELEASE != env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER
}
Expand All @@ -666,17 +673,17 @@ pipeline {
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \
-d '{"tag":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\
"object": "'${COMMIT_SHA}'",\
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to tftp",\
"type": "commit",\
"tagger": {"name": "LinuxServer Jenkins","email": "[email protected]","date": "'${GITHUB_DATE}'"}}' '''
echo "Pushing New release for Tag"
sh '''#! /bin/bash
echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json
curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json
echo '{"tag_name":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\
"target_commitish": "master",\
"target_commitish": "tftp",\
"name": "'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**Remote Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": false}' >> releasebody.json
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": }' >> releasebody.json
paste -d'\\0' start releasebody.json > releasebody.json.done
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,5 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **10.12.19:** - Adding tftp branch to provide tftp only option to latest users.
* **22.10.19:** - Initial release.
11 changes: 5 additions & 6 deletions jenkins-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

# jenkins variables
project_name: docker-netbootxyz
external_type: na
custom_version_command: "curl -sL https://boot.netboot.xyz/ipxe/netboot.xyz-sha256-checksums.txt | grep 'netboot.xyz.kpxe' | cut -c1-8"
release_type: stable
release_tag: latest
ls_branch: master
external_type: github_stable
release_type: pre-release
release_tag: tftp
ls_branch: tftp
repo_vars:
- CONTAINER_NAME = 'netbootxyz'
- BUILD_VERSION_ARG = 'NETBOOTXYZ_SHA'
- BUILD_VERSION_ARG = 'NETBOOTXYZ_RELEASE'
- LS_USER = 'linuxserver'
- LS_REPO = 'docker-netbootxyz'
- DOCKERHUB_IMAGE = 'linuxserver/netbootxyz'
Expand Down
1 change: 1 addition & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ app_setup_block: |
# changelog
changelogs:
- { date: "10.12.19:", desc: "Adding tftp branch to provide tftp only option to latest users." }
- { date: "22.10.19:", desc: "Initial release." }

0 comments on commit 720821d

Please sign in to comment.