cleanning in /compose/debug - part2

This commit is contained in:
Krzysztof Szumny 2015-08-22 13:33:25 +02:00
parent 0da2ed24bd
commit 43098a4cfb
4 changed files with 26 additions and 55 deletions

View File

@ -1,9 +1,5 @@
FROM {{ cookiecutter.repo_name|replace('_', '') }}_django
ENV SFTP_USER docker
ENV SFTP_PASS changeme
ENV PASS_ENCRYPTED false
# Install setuptools, pip and OpenSSH
RUN \
apt-get update && \
@ -15,11 +11,8 @@ RUN mkdir -p /var/run/sshd
# Copy configuration and entrypoint script
COPY sshd_config /etc/ssh/sshd_config
ADD keys_to_docker/id_rsa.pub /ssh_id_rsa.pub
COPY entrypoint /
EXPOSE 22
EXPOSE 8000
ENTRYPOINT ["/entrypoint"]
ENTRYPOINT ["/app/compose/debug/entrypoint.sh"]

View File

@ -1,46 +0,0 @@
#!/bin/bash
# creating user. Default ist user=docker, pass=changeme
# can be changed by setting ENV Variables SFTP_USER, SFTP_PASS
user="${SFTP_USER}"
pass="${SFTP_PASS}"
if [ "${PASS_ENCRYPTED}" == "true" ]; then
chpasswdOptions="-e"
fi
useraddOptions="--create-home --shell /bin/bash"
if [ -n "${USER_UID}" ]; then
useraddOptions="$useraddOptions --non-unique --uid ${USER_UID}"
fi
if [ -n "${USER_GID}" ]; then
useraddOptions="$useraddOptions --gid ${USER_GID}"
groupadd --gid ${USER_GID} ${USER_GID}
fi
useradd $useraddOptions $user
mkdir /home/$user/.ssh
cat /ssh_id_rsa.pub > /home/$user/.ssh/authorized_keys
chown $user:$user /home/$user
chmod 755 /home/$user
chmod 700 /home/$user/.ssh
chmod 700 /home/$user/.ssh
chmod 600 /home/$user/.ssh/authorized_keys
chown -R $user:$user /home/$user/
if [ -z "$pass" ]; then
pass="$(echo `</dev/urandom tr -dc A-Za-z0-9 | head -c256`)"
chpasswdOptions=""
fi
echo "$user:$pass" | chpasswd $chpasswdOptions
# starting ssh (detached)
exec /etc/init.d/ssh start &
exec "$@"

View File

@ -0,0 +1,25 @@
#!/bin/bash
/app/compose/django/entrypoint.sh echo
USER=docker_{{ cookiecutter.repo_name }}
# rename django username to docker_{{ cookiecutter.repo_name }}
usermod -l $USER django
usermod -l $USER -m -d /home/new_username django
groupmod -n $USER django
mkdir /home/$USER/.ssh
cat /app/compose/debug/keys_to_docker/ssh_id_rsa.pub > /home/$USER/.ssh/authorized_keys
chmod 755 /home/$USER
chmod 700 /home/$USER/.ssh
chmod 600 /home/$USER/.ssh/authorized_keys
chown -R $USER:$USER /home/$USER
echo "$USER:docker" | chpasswd
# starting ssh (detached)
exec /etc/init.d/ssh start &
su -c 'python -c "import signal; signal.pause()"' $USER

View File

@ -7,7 +7,6 @@ postgres:
debug:
build: compose/debug/
command: python -c "import signal; signal.pause()"
ports:
- "8000:8000"
- "2222:22"