Skip to content

Commit

Permalink
src/snabb wrapper when building container snabb
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiget committed Feb 22, 2018
1 parent dff8877 commit ba390ec
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ FROM alpine:3.7
RUN apk add --no-cache libgcc
COPY --from=build /snabb/src/snabb /usr/local/bin/

VOLUME /u
WORKDIR /u

ENTRYPOINT ["/usr/local/bin/snabb"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ dist: all

docker:
docker build -t snabb .
@chmod a+rx launch-docker-container.sh
@ln -sf ../launch-docker-container.sh src/snabb
@echo "Usage: docker run -ti --rm snabb <program> ..."
@echo "or simply call 'src/snabb <program> ...'"
.SERIAL: all
33 changes: 33 additions & 0 deletions launch-docker-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

name=$(basename $0)
if [ ".$name" == ".launch-docker-container.sh" ]; then
cat <<EOF
$0
please link this script to the container image you like to run
e.g. to launch latest alpine image with the current working directory mounted:
$ ln -s launch-docker-container.sh alpine
$ ./alpine
/u # ls
alpine launch-docker-container.sh
/u # uname -a
Linux 68b18fa5b4d4 4.9.75-linuxkit-aufs #1 SMP Tue Jan 9 10:58:17 UTC 2018 x86_64 Linux
/u # exit
It also accept arguments:
$ alpine uname -a
Linux 3b18ba5282f3 4.9.75-linuxkit-aufs #1 SMP Tue Jan 9 10:58:17 UTC 2018 x86_64 Linux
$
EOF
exit 1
fi

img=$(docker images -q $name)
if [ -z "$img" ]; then
echo "docker image $name doesn't exist"
fi

exec docker run -ti --rm -v ${PWD}:/u --workdir /u $name $@

0 comments on commit ba390ec

Please sign in to comment.