diff options
author | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-02-12 12:12:34 +0100 |
---|---|---|
committer | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-02-12 12:16:55 +0100 |
commit | 41048f09b545b34ff1ed398b1dd76aad48a98718 (patch) | |
tree | d7de97e4a93bd2f645f75ebda2a1cd51b959f66e /fuel-build/docker/mkimage/mkimage.sh | |
parent | d29df40fd66d6a90fde858e8a0bc0d0e98a01794 (diff) |
Simplification and cleanup of build process
Docker build image:
- Uplift of the base Ubuntu version to 14.04.
- Instead of building the Ubuntu image with debootstrap, we use the official
Docker repository version of Ubuntu.
- Cleanup of the way how runcontext operates
- Fix: Make sure that the build system can be run as root
Top Makefile:
- Building the Fuel ISO on Docker local /tmp directory not to pollute local
directory with files owned by root.
- Removed unused targets.
Change-Id: I684348b2a15546eadf98d810239a84ff9798b1e8
Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
Diffstat (limited to 'fuel-build/docker/mkimage/mkimage.sh')
-rwxr-xr-x | fuel-build/docker/mkimage/mkimage.sh | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/fuel-build/docker/mkimage/mkimage.sh b/fuel-build/docker/mkimage/mkimage.sh deleted file mode 100755 index 3424258..0000000 --- a/fuel-build/docker/mkimage/mkimage.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env bash -############################################################################## -# Copyright (c) 2015 Ericsson AB and others. -# stefan.k.berg@ericsson.com -# jonas.bjurel@ericsson.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -set -e - -mkimg="$(basename "$0")" - -usage() { - echo >&2 "usage: $mkimg [-d dir] [-t tag] script [script-args]" - echo >&2 " ie: $mkimg -t someuser/debian debootstrap --variant=minbase jessie" - echo >&2 " $mkimg -t someuser/ubuntu debootstrap --include=ubuntu-minimal trusty" - echo >&2 " $mkimg -t someuser/busybox busybox-static" - echo >&2 " $mkimg -t someuser/centos:5 rinse --distribution centos-5" - exit 1 -} - -scriptDir="$(dirname "$(readlink -f "$BASH_SOURCE")")" - -optTemp=$(getopt --options '+d:t:h' --longoptions 'dir:,tag:,help' --name "$mkimg" -- "$@") -eval set -- "$optTemp" -unset optTemp - -dir= -tag= -while true; do - case "$1" in - -d|--dir) dir="$2" ; shift 2 ;; - -t|--tag) tag="$2" ; shift 2 ;; - -h|--help) usage ;; - --) shift ; break ;; - esac -done - -script="$1" -[ "$script" ] || usage -shift - -if [ ! -x "$scriptDir/$script" ]; then - echo >&2 "error: $script does not exist or is not executable" - echo >&2 " see $scriptDir for possible scripts" - exit 1 -fi - -# don't mistake common scripts like .febootstrap-minimize as image-creators -if [[ "$script" == .* ]]; then - echo >&2 "error: $script is a script helper, not a script" - echo >&2 " see $scriptDir for possible scripts" - exit 1 -fi - -delDir= -if [ -z "$dir" ]; then - dir="$(mktemp -d ${TMPDIR:-/tmp}/docker-mkimage.XXXXXXXXXX)" - delDir=1 -fi - -rootfsDir="$dir/rootfs" -( set -x; mkdir -p "$rootfsDir" ) - -# pass all remaining arguments to $script -"$scriptDir/$script" "$rootfsDir" "$@" - -# Docker mounts tmpfs at /dev and procfs at /proc so we can remove them -rm -rf "$rootfsDir/dev" "$rootfsDir/proc" -mkdir -p "$rootfsDir/dev" "$rootfsDir/proc" - -# make sure /etc/resolv.conf has something useful in it -mkdir -p "$rootfsDir/etc" -cat > "$rootfsDir/etc/resolv.conf" <<'EOF' -nameserver 8.8.8.8 -nameserver 8.8.4.4 -EOF - -tarFile="$dir/rootfs.tar.xz" -touch "$tarFile" - -( - set -x - tar --numeric-owner -caf "$tarFile" -C "$rootfsDir" --transform='s,^./,,' . -) - -echo >&2 "+ cat > '$dir/Dockerfile'" -cat > "$dir/Dockerfile" <<'EOF' -FROM scratch -ADD rootfs.tar.xz / -EOF - -# if our generated image has a decent shell, let's set a default command -for shell in /bin/bash /usr/bin/fish /usr/bin/zsh /bin/sh; do - if [ -x "$rootfsDir/$shell" ]; then - ( set -x; echo 'CMD ["'"$shell"'"]' >> "$dir/Dockerfile" ) - break - fi -done - -umount $rootfsDir/run/shm -( set -x; rm -rf "$rootfsDir" ) - -if [ "$tag" ]; then - ( set -x; docker build -t "$tag" "$dir" ) -elif [ "$delDir" ]; then - # if we didn't specify a tag and we're going to delete our dir, let's just build an untagged image so that we did _something_ - ( set -x; docker build "$dir" ) -fi - -if [ "$delDir" ]; then - ( set -x; rm -rf "$dir" ) -fi |