From 86a763e0d92f0c50c0b06222d7b6223b70240162 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Fri, 9 Sep 2022 11:37:37 +0200 Subject: [PATCH] initial version --- Dockerfile | 21 +++++++++++++++++++++ README.md | 33 +++++++++++++++++++++++++++++++++ build.sh | 9 +++++++++ rebuild.sh | 14 ++++++++++++++ start.sh | 7 +++++++ 5 files changed, 84 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 build.sh create mode 100755 rebuild.sh create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2a33d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:bookworm-slim + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade -y; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + openssh-server \ + curl \ + telnet \ + net-tools \ + screen \ + ; \ + rm -rf /var/lib/apt/lists/* + +ADD start.sh / + +EXPOSE 22/tcp + +CMD /start.sh + +HEALTHCHECK CMD netstat -tnlp | grep '0.0.0.0:22' || exit 1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd3bbe7 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Jumpbox Docker container + +* Debian slim based image +* OpenSSH server + +# Supported tags and respective `Dockerfile` links + +- [`latest`](https://git.nethuis.nl/pommi/docker-jumpbox/Dockerfile) + +# Usage + +``` +$ docker run -it \ + --name jumpbox \ + -v $(pwd)/authorized_keys:/root/.ssh/authorized_keys \ + -p 1022:22 \ + pommib/jumpbox:latest +``` + +# docker-compose + +``` +version: "3" + +services: + jumpbox: + container_name: jumpbox + image: pommib/jumpbox:latest + ports: + - "1022:22/tcp" + volumes: + - '${PWD}/authorized_keys:/root/.ssh/authorized_keys' +``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0997456 --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -x + +IMAGE=pommib/jumpbox:latest +docker pull $IMAGE +docker pull debian:bookworm-slim +docker build --no-cache -t $IMAGE ./ +docker push $IMAGE diff --git a/rebuild.sh b/rebuild.sh new file mode 100755 index 0000000..350ebb6 --- /dev/null +++ b/rebuild.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +updates_available () { + docker pull $1 + if test "$(docker run -it --rm $1 /bin/sh -c 'apt -qqq update && apt -qq list --upgradable')" != ""; then + return 0 + else + return 1 + fi +} + +if updates_available pommib/jumpbox:latest; then + ./build.sh +fi diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..4117367 --- /dev/null +++ b/start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mkdir -p /run/sshd + +chown root: /root/.ssh/authorized_keys + +exec /usr/sbin/sshd -D -e