Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Sep 24, 2018
1 parent 7b5ef71 commit 43fab0c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
.PHONY: build
build: ## Builds all the dockerfiles in the repository.
./build-all.sh
@$(CURDIR)/build-all.sh

.PHONY: latest-versions
latest-versions: ## Checks all the latest versions of the Dockerfile contents.
./latest-versions.sh
@$(CURDIR)/latest-versions.sh

check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))$(if $(value @), \
required by target `$@')))

.PHONY: run
run: ## Run a Dockerfile from the command at the top of the file (ex. DIR=telnet).
@:$(call check_defined, DIR, directory of the Dockefile)
@$(CURDIR)/run.sh "$(DIR)"

.PHONY: test
test: shellcheck dockerfiles ## Runs the tests on the repository.

.PHONY: dockerfiles
dockerfiles: ## Tests the changes to the Dockefiles build.
./test.sh
@$(CURDIR)/test.sh

# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
DOCKER_FLAGS += -t
endif

.PHONY: shellcheck
Expand Down
19 changes: 11 additions & 8 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# This script allows you to launch several images
# from this repository once they're built.
Expand All @@ -8,29 +8,32 @@
# can find it and execute it.
#
# Use pulseaudio/Dockerfile and skype/Dockerfile as examples.
set -e
set -o pipefail

if [ $# -eq 0 ]; then
if [[ $# -eq 0 ]]; then
echo "Usage: $0 [--test] image1 image2 ..."
exit 1
fi

if [ "$1" = "--test" ]; then
if [[ "$1" = "--test" ]]; then
TEST=1
shift
fi

for name in "$@"; do
if [ ! -d $name ]; then
echo "unable to find container configuration with name $name"
if [[ ! -d "$name" ]]; then
echo "Unable to find container configuration with name: $name"
exit 1
fi

script=`sed -n '/docker run/,/^#$/p' $name/Dockerfile | head -n -1 | sed -e 's/\#//' | sed -e 's/\\\//'`
script=$(sed -n '/docker run/,/^#$/p' "$name/Dockerfile" | head -n -1 | sed "s/#//" | sed "s#\\\##" | tr '\n' ' ' | sed "s/\$@//" | sed 's/""//')
echo "Running: $script"

if [ $TEST ]; then
echo $script
echo "$script"
else
eval $script
eval "$script"
fi

shift
Expand Down
2 changes: 1 addition & 1 deletion telnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# command to run Telnet
# docker run -it --rm \
# --log-driver none \
# jess/telnet "$@"
# jess/telnet towel.blinkenlights.nl
#
FROM alpine:latest
LABEL maintainer "Jessie Frazelle <[email protected]>"
Expand Down

0 comments on commit 43fab0c

Please sign in to comment.