1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tools: updated Docker scripts

This commit is contained in:
Steffen Vogel 2019-03-22 11:20:52 +01:00
parent 58fd0131bc
commit 7c00e054db

View file

@ -1,8 +1,6 @@
#!/bin/bash
# Wrapper to use make and villas commands with docker
#
# Run like this:
# $ source tools/docker.sh
# Start a Docker based development environment
#
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
# @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC
@ -22,29 +20,26 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################################
##################################################################################
# In order to define aliases we need to source this script
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "Please use 'source' to load this script: $ source $0"
exit
fi
SCRIPT=$(realpath ${BASH_SOURCE[0]})
SCRIPTPATH=$(dirname $SCRIPT)
DIR=$(realpath $(dirname $(realpath $BASH_SOURCE))/..)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
SRCDIR=${SRCDIR:-$(realpath ${SCRIPTPATH}/..)}
BUILDDIR=${BUILDDIR:-${SRCDIR}/build}
DOCKER_IMAGE="villas/node-dev:${GIT_BRANCH}"
TAG=${TAG:-develop}
IMAGE="villas/node-dev:${TAG}"
if [[ "$(docker images -q ${DOCKER_IMAGE} 2> /dev/null)" == "" ]]; then
"make" docker-dev
fi
# Start container
docker run --rm --entrypoint bash --detach --tty --volume "${DIR}:/villas" ${DOCKER_IMAGE}
DOCKER="docker exec --tty --env PATH=\"/villas/build/release/:/usr/bin:/bin/\" $(docker ps --latest --quiet)"
# Then define alias for make and node
alias moby="${DOCKER}"
alias make="${DOCKER} make"
alias villas="${DOCKER} bash tools/villas.sh"
docker run \
--interactive \
--tty \
--publish 80:80 \
--publish 443:443 \
--publish 12000:12000/udp \
--publish 12001:12001/udp \
--publish 2345:2345 \
--privileged \
--security-opt seccomp:unconfined \
--volume "${SRCDIR}:/villas" \
${IMAGE}