github.com/iaintshine/docker@v1.8.2/contrib/builder/rpm/generate.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # usage: ./generate.sh [versions]
     5  #    ie: ./generate.sh
     6  #        to update all Dockerfiles in this directory
     7  #    or: ./generate.sh
     8  #        to only update fedora-20/Dockerfile
     9  #    or: ./generate.sh fedora-newversion
    10  #        to create a new folder and a Dockerfile within it
    11  
    12  cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
    13  
    14  versions=( "$@" )
    15  if [ ${#versions[@]} -eq 0 ]; then
    16  	versions=( */ )
    17  fi
    18  versions=( "${versions[@]%/}" )
    19  
    20  for version in "${versions[@]}"; do
    21  	distro="${version%-*}"
    22  	suite="${version##*-}"
    23  	from="${distro}:${suite}"
    24  
    25  	mkdir -p "$version"
    26  	echo "$version -> FROM $from"
    27  	cat > "$version/Dockerfile" <<-EOF
    28  		#
    29  		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/rpm/generate.sh"!
    30  		#
    31  
    32  		FROM $from
    33  	EOF
    34  
    35  	echo >> "$version/Dockerfile"
    36  
    37  	case "$from" in
    38  		centos:*)
    39  			# get "Development Tools" packages dependencies
    40  			echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
    41  
    42  			if [[ "$version" == "centos-7" ]]; then
    43  				echo 'RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs' >> "$version/Dockerfile"
    44  			fi
    45  			;;
    46  		oraclelinux:*)
    47  			# get "Development Tools" packages and dependencies
    48  			echo 'RUN yum groupinstall -y "Development Tools"' >> "$version/Dockerfile"
    49  			;;
    50  		*)
    51  			echo 'RUN yum install -y @development-tools fedora-packager' >> "$version/Dockerfile"
    52  			;;
    53  	esac
    54  
    55  	# this list is sorted alphabetically; please keep it that way
    56  	packages=(
    57  		btrfs-progs-devel # for "btrfs/ioctl.h" (and "version.h" if possible)
    58  		device-mapper-devel # for "libdevmapper.h"
    59  		glibc-static
    60  		libselinux-devel # for "libselinux.so"
    61  		sqlite-devel # for "sqlite3.h"
    62  		tar # older versions of dev-tools do not have tar
    63  	)
    64  
    65  	case "$from" in
    66  		oraclelinux:7)
    67  			# Enable the optional repository
    68  			packages=( --enablerepo=ol7_optional_latest "${packages[*]}" )
    69  			;;
    70  	esac
    71  	echo "RUN yum install -y ${packages[*]}" >> "$version/Dockerfile"
    72  
    73  	echo >> "$version/Dockerfile"
    74  
    75  	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile"
    76  	echo 'RUN curl -fSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local' >> "$version/Dockerfile"
    77  	echo 'ENV PATH $PATH:/usr/local/go/bin' >> "$version/Dockerfile"
    78  
    79  	echo >> "$version/Dockerfile"
    80  
    81  	echo 'ENV AUTO_GOPATH 1' >> "$version/Dockerfile"
    82  
    83  	echo 'ENV DOCKER_BUILDTAGS selinux' >> "$version/Dockerfile"
    84  done