From 1e2b0333fdfc89cb1b666d3ec0dc49036eedb18f Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Tue, 16 Jul 2019 09:16:40 +0300 Subject: [PATCH] Done. --- .dockerignore | 3 +++ .gitignore | 49 +++++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 30 +++++++++++++++++++++++++ Dockerfile | 9 ++++++++ LICENSE.txt | 21 ++++++++++++++++++ README.md | 29 ++++++++++++++++++++++++ entrypoint | 6 +++++ stunnel.conf | 8 +++++++ 8 files changed, 155 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 Dockerfile create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100755 entrypoint create mode 100644 stunnel.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bbe14a2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!entrypoint +!stunnel.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e66e1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,49 @@ +~* +*~ +*.sw[op] +*.py[cod] +.DS_Store +__pycache__/ +.vagrant/ +vendor/ +Thumbs.db +*.retry +.svn/ +.sass-cache/ +*.log +*.out +*.so +node_modules/ +.npm/ +nbproject/ +*.ipynb +.idea/ +*.egg-info/ +*.[ao] +.classpath +.cache/ +bower_components/ +*.class +*.[ewj]ar +secring.* +.*.kate-swp +.swp.* +.directory +.Trash-* +build/ +_build/ +dist/ +.tox/ +*.pdf +*.exe +*.dll +*.gz +*.tgz +*.tar +*.rar +*.zip +*.pid +*.lock +*.env +.bundle/ +!Pipfile.lock diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0d5714c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +# vim:ff=unix ts=2 sw=2 ai expandtab +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.2.3 + hooks: + - id: check-added-large-files + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: detect-private-key + - id: trailing-whitespace + - repo: https://github.com/adrienverge/yamllint + rev: v1.16.0 + hooks: + - id: yamllint + - repo: https://github.com/amperser/proselint + rev: 0.10.2 + hooks: + - id: proselint + types: [plain-text] + exclude: LICENSE + - repo: https://www.shore.co.il/git/shell-pre-commit/ + rev: v0.6.0 + hooks: + - id: shell-lint + - id: shellcheck + - repo: https://www.shore.co.il/git/docker-pre-commit + rev: v0.3.0 + hooks: + - id: hadolint diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f902e15 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.10 +# hadolint ignore=DL3018 +RUN apk add --no-cache ca-certificates stunnel gettext tini +COPY --chown=root:root entrypoint /usr/local/sbin/ +COPY --chown=root:root stunnel.conf /etc/stunnel/stunnel.conf.tmpl +ENTRYPOINT ["entrypoint"] +CMD ["stunnel"] +ENV DEBUG="5" \ + CLIENT="yes" diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..17196c5 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Adar Nimrod + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..acd33bf --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Stunnel Docker image + +> Dockerized stunnel + +## Usage example + +``` +docker run -e 'HOST=foo.example.com' -e 'PORT=443' -p '443:443' adarnimrod/stunnel +``` + +## Environment variables + +Name | Description | Default value +--- | --- | --- +`DEBUG` | Debugging level | `5` (notice) +`PORT` | Port to connect and forward +`CLIENT` | Client mode | `yes` +`HOST` | Remote host + +## License + +This software is licensed under the MIT license (see `LICENSE.txt`). + +## Author Information + +Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my [website]( +https://www.shore.co.il/). Patches are welcome via [`git send-email`]( +http://git-scm.com/book/en/v2/Git-Commands-Email). The repository is located +at: <https://www.shore.co.il/git/>. diff --git a/entrypoint b/entrypoint new file mode 100755 index 0000000..73732c9 --- /dev/null +++ b/entrypoint @@ -0,0 +1,6 @@ +#!/bin/sh +set -eux + +# shellcheck disable=SC2002 +cat /etc/stunnel/stunnel.conf.tmpl | envsubst | tee /etc/stunnel/stunnel.conf +exec tini -- "$@" diff --git a/stunnel.conf b/stunnel.conf new file mode 100644 index 0000000..8aceeb6 --- /dev/null +++ b/stunnel.conf @@ -0,0 +1,8 @@ +debug = ${DEBUG} +foreground = yes +pid = +[redis] +accept = 0.0.0.0:${PORT} +client = ${CLIENT} +connect = ${HOST}:${PORT} +retry = yes -- GitLab