diff --git a/.travis.yml b/.travis.yml
index 09101ce59..f904a2915 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,8 +10,7 @@ env:
- VERSION=${TRAVIS_BRANCH}
script:
- - docker build -t ${NAME}:${VERSION} --rm image
- - env NAME=${NAME} VERSION=${VERSION} ./test/runner.sh
+ - make build test
after_success:
- docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}";
diff --git a/Makefile b/Makefile
index 1b00a21b7..da0e6bed8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,20 @@
-NAME = phusion/baseimage
-VERSION = 0.11
+ifdef BASE_IMAGE
+ BUILD_ARG = --build-arg BASE_IMAGE=$(BASE_IMAGE)
+ifndef NAME
+ NAME = phusion/baseimage-$(subst :,-,${BASE_IMAGE})
+endif
+else
+ NAME ?= phusion/baseimage
+endif
+VERSION ?= 0.11
+
.PHONY: all build test tag_latest release ssh
all: build
build:
- docker build -t $(NAME):$(VERSION) --rm image
+ docker build -t $(NAME):$(VERSION) $(BUILD_ARG) --rm image
test:
env NAME=$(NAME) VERSION=$(VERSION) ./test/runner.sh
@@ -19,13 +27,11 @@ release: test tag_latest
docker push $(NAME)
@echo "*** Don't forget to create a tag by creating an official GitHub release."
+ssh: SSH_COMMAND?=
ssh:
- chmod 600 image/services/sshd/keys/insecure_key
- @ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \
+ ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \
if test "$$ID" = ""; then echo "Container is not running."; exit 1; fi && \
- IP=$$(docker inspect $$ID | grep IPAddr | sed 's/.*: "//; s/".*//') && \
- echo "SSHing into $$IP" && \
- ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i image/services/sshd/keys/insecure_key root@$$IP
+ tools/docker-ssh $$ID ${SSH_COMMAND}
test_release:
echo test_release
diff --git a/README.md b/README.md
index 76baa0fb2..57d978005 100644
--- a/README.md
+++ b/README.md
@@ -597,6 +597,19 @@ If you want to call the resulting image something else, pass the NAME variable,
make build NAME=joe/baseimage
+You can also change the `ubuntu` base-image to `debian` as these distributions are quite similar.
+
+ make build BASE_IMAGE=debian:stretch
+
+The image will be: `phusion/baseimage-debian-stretch`. Use the `NAME` variable in combination with the `BASE_IMAGE` one to call it `joe/stretch`.
+
+ make build BASE_IMAGE=debian:stretch NAME=joe/stretch
+
+To verify that the various services are started, when the image is run as a container, add `test` to the end of your make invocations, e.g.:
+
+ make build BASE_IMAGE=debian:stretch NAME=joe/stretch test
+
+
### Removing optional services
diff --git a/image/Dockerfile b/image/Dockerfile
index da5b41d9f..07a72417d 100644
--- a/image/Dockerfile
+++ b/image/Dockerfile
@@ -1,4 +1,5 @@
-FROM ubuntu:18.04
+ARG BASE_IMAGE=ubuntu:18.04
+FROM $BASE_IMAGE
MAINTAINER Phusion
COPY . /bd_build
diff --git a/image/cleanup.sh b/image/cleanup.sh
index cfe72468f..57e8c7b8c 100755
--- a/image/cleanup.sh
+++ b/image/cleanup.sh
@@ -9,7 +9,7 @@ rm -rf /tmp/* /var/tmp/*
rm -rf /var/lib/apt/lists/*
# clean up python bytecode
-find / -name *.pyc -delete
-find / -name *__pycache__* -delete
+find / -mount -name *.pyc -delete
+find / -mount -name *__pycache__* -delete
rm -f /etc/ssh/ssh_host_*
diff --git a/image/prepare.sh b/image/prepare.sh
index c2926a5d3..d7a383b56 100755
--- a/image/prepare.sh
+++ b/image/prepare.sh
@@ -41,7 +41,16 @@ $minimal_apt_get_install software-properties-common
apt-get dist-upgrade -y --no-install-recommends -o Dpkg::Options::="--force-confold"
## Fix locale.
-$minimal_apt_get_install language-pack-en
+case $(lsb_release -is) in
+ Ubuntu)
+ $minimal_apt_get_install language-pack-en
+ ;;
+ Debian)
+ $minimal_apt_get_install locales locales-all
+ ;;
+ *)
+ ;;
+esac
locale-gen en_US
update-locale LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
echo -n en_US.UTF-8 > /etc/container_environment/LANG
diff --git a/test/runner.sh b/test/runner.sh
index 5a3c98d88..322318189 100755
--- a/test/runner.sh
+++ b/test/runner.sh
@@ -14,10 +14,8 @@ function cleanup()
docker rm $ID >/dev/null
}
-PWD=`pwd`
-
echo " --> Starting insecure container"
-ID=`docker run -d -p 22 -v $PWD/test:/test $NAME:$VERSION /sbin/my_init --enable-insecure-key`
+ID=`docker run -d -p 22 $NAME:$VERSION /sbin/my_init --enable-insecure-key`
sleep 1
echo " --> Obtaining SSH port number"
@@ -29,14 +27,12 @@ fi
trap cleanup EXIT
echo " --> Enabling SSH in the container"
-docker exec -t -i $ID /etc/my_init.d/00_regen_ssh_host_keys.sh -f
-docker exec -t -i $ID rm /etc/service/sshd/down
-docker exec -t -i $ID sv start /etc/service/sshd
+docker exec $ID /etc/my_init.d/00_regen_ssh_host_keys.sh -f
+docker exec $ID rm /etc/service/sshd/down
+docker exec $ID sv start /etc/service/sshd
sleep 1
echo " --> Logging into container and running tests"
-cp image/services/sshd/keys/insecure_key /tmp/insecure_key
-chmod 600 /tmp/insecure_key
sleep 1 # Give container some more time to start up.
-ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/insecure_key -p $SSHPORT root@127.0.0.1 \
- /bin/bash /test/test.sh
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+tools/docker-ssh $ID bash < test/test.sh
diff --git a/tools/docker-ssh b/tools/docker-ssh
index 599a13249..715f345a3 100755
--- a/tools/docker-ssh
+++ b/tools/docker-ssh
@@ -58,6 +58,13 @@ fi
KNOWN_HOSTS_FILE=`mktemp /tmp/docker-ssh.XXXXXXXXX`
IP=`docker inspect -f "{{ .NetworkSettings.IPAddress }}" "$CONTAINER_ID"`
+PORT=`docker inspect -f '{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' "$CONTAINER_ID"`
+if test "`uname`" = "Darwin"; then
+ IP="127.0.0.1"
+else
+ PORT=22
+fi
+echo "SSHing into $IP:$PORT"
# Prevent SSH from warning about adding a host to the known_hosts file.
ssh-keyscan "$IP" >"$KNOWN_HOSTS_FILE" 2>&1
@@ -68,6 +75,7 @@ if ! ssh -i ~/.baseimage_docker_insecure_key \
-o PasswordAuthentication=no \
-o KbdInteractiveAuthentication=no \
-o ChallengeResponseAuthentication=no \
+ -p $PORT \
"root@$IP" "$@"
then
STATUS=$?