From 7def25b621fb3c090599d4d89d9ff98ba7bd413a Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 8 Feb 2018 13:57:29 +0100 Subject: [PATCH] Port to alpine as a base container Signed-off-by: Knut Ahlers --- Dockerfile | 17 ++++++++--------- start.sh | 3 ++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index ab9de06..5bfd397 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,19 @@ -FROM ubuntu:14.04 -MAINTAINER Knut Ahlers +FROM alpine + +LABEL maintainer Knut Ahlers ENV USER share ENV PASS changeme ENV USER_UID 1000 -ENV DI_VERSION 1.0.1 -ENV DI_HASH 91b9970e6a0d23d7aedf3321fb1d161937e7f5e6ff38c51a8a997278cc00fb0a +ENV DI_VERSION 1.2.1 -ADD https://github.com/Yelp/dumb-init/releases/download/v1.0.1/dumb-init_${DI_VERSION}_amd64 /usr/local/bin/dumb-init -RUN apt-get update \ - && apt-get install -y openssh-server mcrypt \ +RUN apk --no-cache add bash curl openssh-server openssl shadow \ && mkdir /var/run/sshd && chmod 0755 /var/run/sshd \ - && echo "${DI_HASH} /usr/local/bin/dumb-init" | sha256sum -c \ - && chmod +x /usr/local/bin/dumb-init + && curl -sSfLo /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DI_VERSION}/dumb-init_${DI_VERSION}_amd64 \ + && chmod +x /usr/local/bin/dumb-init \ + && apk --no-cache del curl ADD start.sh /usr/local/bin/start.sh ADD sshd_config /etc/ssh/sshd_config diff --git a/start.sh b/start.sh index 76c6e2a..ecacd67 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail for type in rsa dsa ecdsa ed25519; do if ! [ -e "/ssh/ssh_host_${type}_key" ]; then @@ -13,7 +14,7 @@ if ( id ${USER} ); then echo "INFO: User ${USER} already exists" else echo "INFO: User ${USER} does not exists, we create it" - ENC_PASS=$(perl -e 'print crypt($ARGV[0], "password")' ${PASS}) + ENC_PASS=$(echo ${PASS} | openssl passwd -1 -stdin) useradd -d /data -m -p ${ENC_PASS} -u ${USER_UID} -s /bin/sh ${USER} fi