Files
domo/bsp/scripts/docker-build.sh

46 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
echo "Build Docker Image."
stagingPath=$1
projectPath=$2
projectName=$3
version=$4
echo "Staging: $stagingPath"
echo "projectPath: $projectPath"
echo "projectName: $projectName"
echo "version: $version"
HAS_IMAGE=`docker image ls ${projectName}:v${version} | wc -l`
if [ $HAS_IMAGE -eq "2" ]; then
echo "The image existe we remove it first"
docker image rm -f ${projectName}:v${version}
fi
rm -rf $stagingPath/docker-build
mkdir -p $stagingPath/docker-build/rootfs/
mkdir -p $stagingPath/docker-build/rootfs/dev
mkdir -p $stagingPath/docker-build/rootfs/media
mkdir -p $stagingPath/docker-build/rootfs/mnt
mkdir -p $stagingPath/docker-build/rootfs/proc
mkdir -p $stagingPath/docker-build/rootfs/run
mkdir -p $stagingPath/docker-build/rootfs/srv
mkdir -p $stagingPath/docker-build/rootfs/sys
mkdir -p $stagingPath/docker-build/rootfs/tmp
mkdir -p $stagingPath/docker-build/rootfs/usr/local/
cp $projectPath/configs/Dockerfile $stagingPath/docker-build
cp -a $stagingPath/buildroot/target/bin $stagingPath/docker-build/rootfs/
cp -a $stagingPath/buildroot/target/etc $stagingPath/docker-build/rootfs/
cp -a $stagingPath/buildroot/target/lib $stagingPath/docker-build/rootfs/
cp -a $stagingPath/buildroot/target/sbin $stagingPath/docker-build/rootfs/
cp -a $stagingPath/buildroot/target/var $stagingPath/docker-build/rootfs/
touch $stagingPath/docker-build/rootfs/etc/resolv.conf
touch $stagingPath/docker-build/rootfs/sbin/init
docker build -t ${projectName}:v${version} $stagingPath/docker-build