From b26ed8afb0aee161b9e757f09859f9fb2f5412c7 Mon Sep 17 00:00:00 2001 From: Roberto Salgado Ladrero Date: Tue, 9 Oct 2018 19:21:58 +0200 Subject: [PATCH 1/4] Ignore backup files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 48f8d66..f0bb928 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__ venv/ .idea/ ssh_unlocker.egg-info/ +*~ From 51fecdc96fff496cd820316ebc5e25c85bb3eb8d Mon Sep 17 00:00:00 2001 From: Roberto Salgado Ladrero Date: Tue, 9 Oct 2018 19:22:51 +0200 Subject: [PATCH 2/4] Add Dockerfile to build Docker Image --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..105eb4e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3-slim + +LABEL maintainer drober+python@gmail.com + +WORKDIR /usr/src/app +VOLUME /usr/src/conf +ENV SSH_UNLOCK_VERBOSE "" + +COPY . . +RUN pip3 install . +CMD [ "python", "./unlock.py", "--config", "/usr/src/conf/config.ini"] From 94e284e9f444245109d81a3771018417534cc90f Mon Sep 17 00:00:00 2001 From: Roberto Salgado Ladrero Date: Tue, 9 Oct 2018 19:46:33 +0200 Subject: [PATCH 3/4] Add Dockerfile README --- README.Dockerfile.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 README.Dockerfile.md diff --git a/README.Dockerfile.md b/README.Dockerfile.md new file mode 100644 index 0000000..ad8d3f8 --- /dev/null +++ b/README.Dockerfile.md @@ -0,0 +1,19 @@ +# Building a Docker image +Simply run `./build_docker.sh` with no parameters. It'll create an image called `ssh-unlock:VERSION` +where VERSION is based on specified version of unlocker library. + +If first arg is set it will create `$1:ssh-unlock:VERSION` so you can upload it easier to DockerHub if you want to. + +# Running a container +At this time this Dockerfile is capable of using file configuration only as `config.ini`, which should be mounted in container's `/usr/src/config` directory. + +All private keys or configuration must be in this directory and properly referenced in configuration file `config.ini`. Mind that inside container all these files would be in `/usr/src/config/your_expeted_file`. This means that using `ConfigMap` object it could run easily on Kubernetes. + +## Docker run example +`docker run -ti --rm -v $HOME/ssh-unlock/config/:/usr/src/config/ ssh-unlock:0.2` + +## Docker run example as daemon +`docker run -d --name ssh-unlock -v $HOME/ssh-unlock/config/:/usr/src/config/ ssh-unlock:0.2` + +## See daemon logs +`docker logs -f ssh-unlock` From 648c1f32dbfa3eb5de2c206bc9983848bae169b1 Mon Sep 17 00:00:00 2001 From: Roberto Salgado Ladrero Date: Tue, 9 Oct 2018 19:48:15 +0200 Subject: [PATCH 4/4] Add Docker Image builder --- build_docker.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 build_docker.sh diff --git a/build_docker.sh b/build_docker.sh new file mode 100755 index 0000000..04b7555 --- /dev/null +++ b/build_docker.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +UNLOCK_VERSION=${UNLOCK_VERSION:-$(awk -F \' '{if($1="__version__ ="){print $2;exit}}' unlocker/__init__.py)} + +if [ ! -z ${UNLOCK_VERSION} ] +then + echo "[$0] No image version specified not obtained from source. Set UNLOCK_VERSION env var to build this" + exit 1 +fi + +if [ ! -z $1 ] +then + docker build . -t $1/ssh-unlock:${UNLOCK_VERSION} +else + docker build . -t ssh-unlock:${UNLOCK_VERSION} +fi