mirror of
https://github.com/phusion/baseimage-docker.git
synced 2026-03-26 04:18:46 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -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}";
|
||||
|
||||
22
Makefile
22
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
|
||||
|
||||
13
README.md
13
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
|
||||
|
||||
|
||||
<a name="removing_optional_services"></a>
|
||||
### Removing optional services
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
FROM ubuntu:18.04
|
||||
ARG BASE_IMAGE=ubuntu:18.04
|
||||
FROM $BASE_IMAGE
|
||||
MAINTAINER Phusion <info@phusion.nl>
|
||||
|
||||
COPY . /bd_build
|
||||
|
||||
@@ -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_*
|
||||
|
||||
@@ -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.
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=$?
|
||||
|
||||
Reference in New Issue
Block a user