summaryrefslogtreecommitdiff
path: root/imagebuild/coreos/docker_build.bash
blob: f3c74769617e7ced4e0b1fe56587c7d67aa8ff00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#
# docker_build.bash - Prepares and outputs a tarball'd docker repository
#                     suitable for injection into a coreos pxe image
#

set -e

OUTPUT_FILE="oem/container.tar.gz"

# If there's already a container.tar.gz, don't overwrite it -- instead, bail
if [[ -e "${OUTPUT_FILE}" ]]; then
  echo "${OUTPUT_FILE} already exists. Will not overwrite. Exiting."
  exit 1
fi

# Build the docker image
cd ../../
docker build -t oemdocker .
cd -

# Create a UUID to identify the build
CONTAINER_UUID=`uuidgen`

# Export the oemdocker repository to a tarball so it can be embedded in CoreOS
# TODO: Investigate running a container and using "export" to flatten the
#       image to shrink the CoreOS fs size. This will also require run.sh to
#       use docker import instead of docker load as well.
docker run oemdocker echo $CONTAINER_UUID
CONTAINER=`docker ps -a --no-trunc |grep $CONTAINER_UUID|awk '{print $1}'|head -n1`
echo $CONTAINER
docker export $CONTAINER | gzip > ${OUTPUT_FILE}