From 483071ed8655540578733b86b7c99679f92d39a3 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Tue, 14 Sep 2021 19:17:31 +0200 Subject: [PATCH] Fixed mistakes, and added inital Documentation --- CT-Build/Alpine.Jenkinsfile | 2 +- CT-Build/Debian.Jenkinsfile | 2 +- CT-Files/Jenkins/Scripts/FirstRun.sh | 6 ++--- Readme.md | 38 ++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Readme.md diff --git a/CT-Build/Alpine.Jenkinsfile b/CT-Build/Alpine.Jenkinsfile index 12a6f5f..028d9cc 100644 --- a/CT-Build/Alpine.Jenkinsfile +++ b/CT-Build/Alpine.Jenkinsfile @@ -47,7 +47,7 @@ pipeline { if $ZX_Multicore; then export XZ_DEFAULTS="-T $ZX_Cores" fi - sudo $WORKSPACE/distrobuilder build-lxc Alpine.yaml $WORKSPACE/REL/$ImgVariant/ -o image.variant=$ImgVariant + sudo $WORKSPACE/distrobuilder build-lxc CT-Build/Alpine.yaml $WORKSPACE/REL/$ImgVariant/ -o image.variant=$ImgVariant sudo chown jenkins:jenkins -R $WORKSPACE/REL mv $WORKSPACE/REL/$ImgVariant/rootfs.tar.xz Alpine-$ImgVariant.tar.xz ''' diff --git a/CT-Build/Debian.Jenkinsfile b/CT-Build/Debian.Jenkinsfile index 17e74c7..1376ac4 100644 --- a/CT-Build/Debian.Jenkinsfile +++ b/CT-Build/Debian.Jenkinsfile @@ -47,7 +47,7 @@ pipeline { if $ZX_Multicore; then export XZ_DEFAULTS="-T $ZX_Cores" fi - sudo $WORKSPACE/distrobuilder build-lxc Debian.yaml $WORKSPACE/REL/$ImgVariant/ -o image.variant=$ImgVariant + sudo $WORKSPACE/distrobuilder build-lxc CT-Build/Debian.yaml $WORKSPACE/REL/$ImgVariant/ -o image.variant=$ImgVariant sudo chown jenkins:jenkins -R $WORKSPACE/REL mv $WORKSPACE/REL/$ImgVariant/rootfs.tar.xz Debian-$ImgVariant.tar.xz ''' diff --git a/CT-Files/Jenkins/Scripts/FirstRun.sh b/CT-Files/Jenkins/Scripts/FirstRun.sh index 2f4c932..031f4e5 100644 --- a/CT-Files/Jenkins/Scripts/FirstRun.sh +++ b/CT-Files/Jenkins/Scripts/FirstRun.sh @@ -4,7 +4,7 @@ ThisScriptConfigured=no GitRepo=https://git.bprieshof.nl/brammp/HS-Testing.git JenkinsUsername= JenkinsPassword= -LXCBuilderIP= +LXCBuilderIP= #StaticVars AdminPassword=$(cat /var/lib/jenkins/secrets/initialAdminPassword) @@ -41,8 +41,8 @@ sleep 60 #Add Jobs cat /opt/Setup/Configs/FolderJob.xml | sed -e 's/FoldersVersions/'$(printf "%s" "${InstalledPlugins%x}" | grep '^cloudbees-folder ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#Other-Builds/DistroBuilder.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/DistroBuilder -cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#/CT-Build/Debian.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/Debian-LXC -cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#/CT-Build/Alpine.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/Alpine-LXC +cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#CT-Build/Debian.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/Debian-LXC +cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#CT-Build/Alpine.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/Alpine-LXC #Add Node cat /opt/Setup/Configs/LXCBuilder1.xml | sed -e 's/SSHAgentVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^golang ' | awk '{ print $NF}')'/g' -e 's/LXCBuilderIP/'$LXCBuilderIP'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-node LXCBuilder1 diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..3440398 --- /dev/null +++ b/Readme.md @@ -0,0 +1,38 @@ +# Scripts for building containers for the Proxmox home server + +# Inital Setup +The fist step is to build the containers needed for building all other containers. +This can be done on a Minimal debian CT (make sure to enable nesting) on the new proxmox server or any other debian install + +1. Clone this repo +2. cd in to cloned repo +3. run `bash Scripts/FirstSetup.sh`, to genate the container images +4. upload the `Debian-imgbuilder.tar.xz` to the proxmox server and create a privileged container +5. Follow the steps under Container Setup > imgbuilder +6. +7. Follow the steps under Container Setup > Jenkins + +# List of containers + + +# Container Setup +## imgbuilder +**This container shoud be set up as privileged** +1. Enable features: Fuse, Nesting and 'Create Device Nodes' +2. Add a mountpoint to /LXCBuild on a accesable place for the Proxmox Server +3. Add this location to datastore for LXC templates to Proxmox +4. Set the `jenkins` user password using `passwd jenkins` in the container +5. Create folders on mountpoint using `mkdir /LXCBuild/template/cache` +6. Set permissions on the folder `chmod o+w -R /LXCBuild` +7. Write down the ip of this server (for use in the jenkins container) +## Jenkins +1. In the container configure the setup script `nano /opt/Setup/Scripts/FirstRun.sh` +2. In the container run the setup script `bash /opt/Setup/Scripts/FirstRun.sh` +3. Acces Jenkins using `http://:8080` +4. Press the `X` to skip the fist time setup +5. Delete the `Admin` user go to 'Manage Jenkins' > 'Manage Users' > Admin > Delete +6. Add credentials for imgbuilder-CT go to 'Manage Jenkins' > 'Manage Nodes and Clouds' > LXCBuilder1 > configure +Under Credentials click 'Add', enter 'jenkins' as username, and set the password that was set in the imgbuilder CT +Then select the created credential and click save +7. Click 'Relaunch agent' +8. Now you can build container images \ No newline at end of file