Skip to content

Instantly share code, notes, and snippets.

@binzume binzume/dock2local.sh
Last active Oct 16, 2015

Embed
What would you like to do?
DockerfileあるのにVMに直接環境作りたくなったときに使うヤツ
#!/bin/sh
# Apply a Dockerfile to local environment.
# usage: sudo ./dock2local.sh [PATH_TO_Dockerfile]
DOCKERFILE=${1:-Dockerfile}
DOCKERFILE=`dirname $DOCKERFILE`/`basename $DOCKERFILE`
LOCALDIR=$(cd `dirname $DOCKERFILE` && pwd)
D_WORKDIR=`pwd`
D_USER=`whoami`
D_CMD=""
FROM() {
echo "# FROM: $@"
uname -a
}
MAINTAINER() {
echo "# MAINTAINER: $@"
}
RUN() {
# TODO: sudo - $D_USER
cd $D_WORKDIR; $@ || exit
}
ADD() {
cd $D_WORKDIR; mkdir -p `dirname $2`
cd $D_WORKDIR; cp $LOCALDIR/$1 $2 || exit
}
COPY() {
cd $D_WORKDIR; mkdir -p `dirname $2`
cd $D_WORKDIR; cp $1 $2 || exit
}
CMD() {
D_CMD=$@
}
WORKDIR() {
mkdir -p $1 || exit
D_WORKDIR=$1
}
USER() {
D_USER=$1
}
ENV() {
# Key=Value only...
echo export $@ >> /etc/profile
}
VOLUME() {
# single volume only...
mkdir -p $1
}
EXPOSE() {
echo "EXPOSE: not supported."
}
echo "$DOCKERFILE start..."
source $DOCKERFILE
#if [ $D_CMD ] ; then
# crontab -l | { cat; echo "@reboot $D_CMD"; } | crontab -
# $D_CMD
#fi
echo "finished."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.