diff --git a/Alpine.yaml b/Alpine.yaml new file mode 100644 index 0000000..92838bd --- /dev/null +++ b/Alpine.yaml @@ -0,0 +1,158 @@ +image: + distribution: "alpinelinux" + +source: + downloader: alpinelinux-http + same_as: 3.12 + url: http://192.168.2.83/alpine/ + keys: + - 0482D84022F52DF1C4E7CD43293ACD0907D9495A + +targets: + lxc: + create-message: | + You just created an {{ image.description }} container. + + config: + - type: all + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/sabayon.common.conf + + - type: user + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/sabayon.userns.conf + + - type: all + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/common.conf + + - type: user + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/userns.conf + + - type: all + content: |- + lxc.arch = {{ image.architecture_kernel }} + +files: +- path: /etc/hostname + generator: hostname + +- path: /etc/hosts + generator: hosts + +- path: /var/lib/dbus/machine-id + generator: remove + +- path: /etc/netplan/10-lxc.yaml + generator: dump + content: |- + + +- path: /etc/network/interfaces + generator: dump + content: |- + auto eth0 + iface eth0 inet dhcp + hostname $(hostname) + +- path: /etc/inittab + generator: dump + content: |- + # /etc/inittab + ::sysinit:/sbin/openrc sysinit + ::sysinit:/sbin/openrc boot + ::wait:/sbin/openrc default + + # Set up a couple of getty's + ::respawn:/sbin/getty 38400 console + #tty1::respawn:/sbin/getty 38400 tty1 + #tty2::respawn:/sbin/getty 38400 tty2 + #tty3::respawn:/sbin/getty 38400 tty3 + #tty4::respawn:/sbin/getty 38400 tty4 + + # Stuff to do for the 3-finger salute + ::ctrlaltdel:/sbin/reboot + + # Stuff to do before rebooting + ::shutdown:/sbin/openrc shutdown + +- path: /etc/inittab + generator: template + name: inittab + content: |- + # /etc/inittab + ::sysinit:/sbin/openrc sysinit + ::sysinit:/sbin/openrc boot + ::wait:/sbin/openrc default + + # Set up a couple of getty's + ::respawn:/sbin/getty 38400 console + + # Stuff to do for the 3-finger salute + ::ctrlaltdel:/sbin/reboot + + # Stuff to do before rebooting + ::shutdown:/sbin/openrc shutdown + +packages: + manager: apk + update: true + cleanup: true + sets: + - packages: + - alpine-base + action: install + - packages: + - nano + action: install + variants: + - default + + repositories: + - name: /etc/apk/repositories + url: |- + http://192.168.2.83/alpine/v{{ image.release }}/main + http://192.168.2.83/alpine/v{{ image.release }}/community + #http://192.168.200.83/alpine/v{{ image.release }}/main + #http://192.168.200.83/alpine/v{{ image.release }}/community + +actions: +- trigger: post-unpack + action: |- + #!/bin/sh + sed -i '/dl-cdn.alpinelinux.org/d' /etc/apk/repositories + +- trigger: post-unpack + action: |- + #!/bin/sh + sed -i 's/vedge/edge/g' /etc/apk/repositories + releases: + - edge + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + + # Rewrite configuration for LXC + sed -i 's/#rc_sys=""/rc_sys="lxc"/' /etc/rc.conf + + # Enable services + for svc_name in bootmisc syslog; do + ln -s /etc/init.d/${svc_name} /etc/runlevels/boot/${svc_name} + done + + for svc_name in networking crond; do + ln -s /etc/init.d/${svc_name} /etc/runlevels/default/${svc_name} + done + types: + - container + +mappings: + architecture_map: alpinelinux + diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e7153b7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,89 @@ +pipeline { + agent { label 'LXCBuilder' } + parameters { + booleanParam defaultValue: true, description: 'Builds Default images', name: 'BuildDefault' + booleanParam defaultValue: false, description: 'Builds Extra images', name: 'BuildExtra' + } + options { + skipDefaultCheckout() + buildDiscarder(logRotator(numToKeepStr: '2', artifactNumToKeepStr: '1')) + } + stages { + stage('Prepare') { + steps { + // Cleanup before starting + cleanWs() + // Checkout the repository + checkout scm + // Get distrobuilder + copyArtifacts filter: 'bin/distrobuilder', fingerprintArtifacts: true, flatten: true, projectName: '/Public/DistroBuilder/BuildConfig=BrampCustom', selector: lastSuccessful() + // Setup Env + sh '''mkdir $WORKSPACE/REL''' + } + } + stage("Image Configs") { + matrix { + axes { + axis { + name 'ImgRelease' + values '3.13', 'edge' + } + axis { + name 'ImgVariant' + values 'Default-minmal', 'Default-default' + } + } + // //Exclude unwanted conbinatinations + // excludes { + // exclude { + // axis { + // name 'ImgRelease' + // values 'edge' + // } + // axis { + // name 'ImgVariant' + // //use notValues to invert + // values 'Extra-extended' + // } + // } + // } + stages { + stage('Build image') { + when { + //ImgTypeTest + anyOf { + allOf { + expression { return (env.ImgVariant).startsWith('Default-') } + environment name: 'BuildDefault', value: 'true' + } + allOf { + expression { return (env.ImgVariant).startsWith('Extra-') } + environment name: 'BuildExtra', value: 'true' + } + } + } + steps { + // Build script + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh '''echo "$(date) Do Build for $ImgRelease - $ImgVariant" + ImgVariantName=${ImgVariant#Default-} && ImgVariantName=${ImgVariantName#Extra-} + sudo $WORKSPACE/distrobuilder build-lxc Alpine.yaml $WORKSPACE/REL/$ImgRelease-$ImgVariant/ -o image.release=$ImgRelease -o image.variant=$ImgVariantName + sudo chown jenkins:jenkins -R $WORKSPACE/REL + mv $WORKSPACE/REL/$ImgRelease-$ImgVariant/rootfs.tar.xz Alpine-$ImgRelease-$ImgVariant.tar.xz + ''' + } + } + } + } + } + } + stage('Finish') { + steps { + // Save generated files + archiveArtifacts artifacts: '*.tar.xz', followSymlinks: false + // Cleaning WorkSpace + //cleanWs() + } + } + } +} \ No newline at end of file