Skip to content

Commit

Permalink
pritunl docker recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
fscm committed Feb 25, 2019
0 parents commit d1b53db
Show file tree
Hide file tree
Showing 8 changed files with 663 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Docker
!.gitkeep

# macOS
*.DS_Store
.AppleDouble
.LSOverride
._*

# Linux
*~

# Windows
Desktop.ini
Thumbs.db

26 changes: 26 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[author]: # (Frederico Martins <http:https://github.com/fscm>)
[version]: # (1.0)
[license]: # (SPDX-License-Identifier: CC-BY-4.0)
[copyright]: # (2016-2019, Frederico Martins)

This project follows a No Code of Conduct (NCoC) philosophy. We are all human
beings. We should all be capable of getting along well.

# Contributor (No) Code of Conduct

Everyone is expected to behave like an adult and therefore be capable of
having adult discussions. Everyone contributions are accepted regardless of
their level of experience, gender, gender identity and expression, sexual
orientation, disability, personal appearance, body size, race, ethnicity, age,
religion, or nationality. The owners or copyright holders of this project are
not members of a support group for human emotion. This is a community that
strives to focus around its topics. Anything else takes away from that.

Everyone should be able to freely express their ideas without being offended
by nor offend others.

PROBLEMS, OR OTHER SITUATIONS, SHOULD BE ADDRESSED LIKE IN ANY OTHER PLATFORM,
PROJECT OR DISCUSSION FORUM. IN NO EVENT SHALL THE OWNERS OR COPYRIGHT HOLDERS
OF THIS PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
THIS PROJECT COMMUNITY.
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing

If you are thinking of contributing code to this project, first of all, thank
you! All fixes, patches and enhancements to it are very warmly welcomed.

Please take a moment to review this document in order to find how your
contribution can be possible.

## Bugs and Feature Requests

The preferred way to report bugs or request features is to use
[GitHub issues](issues). For this project, however, that feature is not
available.

## Pull Requests

1. Create a [GitHub account](https://github.com/join) (if you don't have one already)
2. [Fork](https://help.github.com/articles/fork-a-repo) this project
3. Create your feature branch: `git checkout -b my-new-feature`
4. Make your changes
5. Commit your changes: `git commit -am 'Add some feature'`
6. Push to the branch: `git push origin my-new-feature`
7. Submit a pull request

Before you submit a
[pull request](https://help.github.com/articles/using-pull-requests/) from your
forked repo, check that it meets these guidelines:

- If the pull request adds or changes a functionality, make sure the
documentation is also created or updated as part of the same pull request.
- Try not to put more than one feature or bug fix in a single pull request. Create a
separate pull request for each feature or bug fix.
- Squash your commits into one for each pull request: `git reset --soft HEAD~<NUMBER_OF_COMMITS> && git commit`.

## License

By contributing to this project, you agree that your contributions will be licensed under its [LICENSE](LICENSE).
112 changes: 112 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
FROM fscm/debian:stretch as build

ARG BUSYBOX_VERSION="1.30.0"
ARG GOLANG_VERSION="1.11.5"
ARG PYTHON_VERSION="2.7.15"
ARG PRITUNL_VERSION="1.29.1979.98"

ENV DEBIAN_FRONTEND=noninteractive

COPY files/* /usr/local/bin/

RUN \
apt-get -qq update && \
apt-get -qq -y -o=Dpkg::Use-Pty=0 --no-install-recommends install \
autoconf autotools-dev bzip2 curl g++ gcc git make tar \
blt-dev tcl-dev tk-dev zlib1g-dev \
ca-certificates iptables net-tools openssl openvpn \
libbluetooth-dev libbz2-dev libc-dev libdb-dev libexpat1-dev libffi-dev \
libgdbm-dev libgpm2 liblzma-dev libncursesw5-dev libreadline-dev \
libsqlite3-dev libssl-dev libtinfo-dev \
lsb-release \
sharutils && \
sed -i '/path-include/d' /etc/dpkg/dpkg.cfg.d/90docker-excludes && \
mkdir -p /build/data/pritunl && \
mkdir -p /src/apt/dpkg && \
chmod -R o+rw /src/apt && \
cp -r /var/lib/dpkg/* /src/apt/dpkg/ && \
cd /src/apt && \
apt-get -qq -y -o=Dpkg::Use-Pty=0 download bash ca-certificates iptables net-tools openssl openvpn && \
dpkg --unpack --force-all --no-triggers --instdir=/build --admindir=/src/apt/dpkg --path-exclude="/usr/share*" openssl_*.deb && \
dpkg --unpack --force-all --no-triggers --instdir=/build --admindir=/src/apt/dpkg --path-exclude="/usr/share*" iptables_*.deb && \
dpkg --unpack --force-all --no-triggers --instdir=/build --admindir=/src/apt/dpkg --path-exclude="/etc*" --path-exclude="/usr/share*" bash_*.deb && \
dpkg --unpack --force-all --no-triggers --instdir=/build --admindir=/src/apt/dpkg --path-exclude="/usr/*" --path-include="/usr/sbin*" net-tools_*.deb && \
dpkg --unpack --force-all --no-triggers --instdir=/build --admindir=/src/apt/dpkg --path-exclude="/etc*" --path-exclude="/lib*" --path-exclude="/usr/*" --path-include="/usr/lib*" --path-include="/usr/sbin*" openvpn_*.deb && \
dpkg --unpack --force-all --no-triggers --instdir=/build --admindir=/src/apt/dpkg --path-exclude="/etc*" --path-exclude="/usr/sbin*" --path-exclude="/usr/share/*" --path-include="/usr/share/ca-certificates*" ca-certificates_*.deb && \
ln -s /bin/bash /build/bin/sh && \
for f in `find /build -name '*.dpkg-new'`; do mv "${f}" "${f%.dpkg-new}"; done && \
update-ca-certificates --etccertsdir /build/etc/ssl/certs/ && \
cd - && \
mkdir -p /src/python && \
curl -sL --retry 3 --insecure "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-${PYTHON_VERSION}.tgz" | tar xz --no-same-owner --strip-components=1 -C /src/python/ && \
cd /src/python && \
rm -rf Modules/expat && \
rm -rf Modules/zlib && \
for d in darwin libffi libffi_arm_wince libffi_msvc libffi_osx; do rm -r Modules/_ctypes/${d}; done && \
for f in md5module.c md5.c shamodule.c sha256module.c sha512module.c; do rm Modules/${f}; done && \
CFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security" LDFLAGS="-Wl,-z,relro" ./configure \
--build="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
--quiet \
--prefix="" \
--enable-ipv6 \
--enable-shared \
--enable-unicode=ucs4 \
--with-computed-gotos \
--with-dbmliborder=bdb:gdbm \
--with-fpectl \
--with-system-expat \
--with-system-ffi \
--with-ensurepip=install && \
make --silent && \
make --silent install DESTDIR=/build && \
ln -s /build/bin/python2.7 /bin/python2.7 && \
cd - && \
mkdir -p /opt/golang && \
curl -sL --retry 3 --insecure "https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz" | tar xz --no-same-owner --strip-components=0 -C /opt/golang/ && \
PATH=$PATH:/opt/golang/go/bin GOPATH=/opt/golang GOBIN=/build/bin go get -u github.com/pritunl/pritunl-dns && \
PATH=$PATH:/opt/golang/go/bin GOPATH=/opt/golang GOBIN=/build/bin go get -u github.com/pritunl/pritunl-web && \
mkdir /src/pritunl && \
curl -sL --retry 3 --insecure "https://github.com/pritunl/pritunl/archive/${PRITUNL_VERSION}.tar.gz" | tar xz --no-same-owner --strip-components=1 -C /src/pritunl/ && \
cd /src/pritunl && \
for f in $(grep -Rl 'var/lib/pritunl' /src/pritunl/*); do sed -i 's,var/lib/pritunl,data/pritunl,g' ${f}; done && \
PATH=$PATH:/build/bin LD_LIBRARY_PATH=/build/lib /bin/python2.7 -E setup.py --quiet build --no-systemd && \
PATH=$PATH:/build/bin LD_LIBRARY_PATH=/build/lib CFLAGS=-I/build/include CPPFLAGS=-I/build/include LDFLAGS=-L/build/lib pip install --quiet --requirement requirements.txt && \
PATH=$PATH:/build/bin LD_LIBRARY_PATH=/build/lib /bin/python2.7 -E setup.py --quiet install --no-systemd --root /build/ --prefix "" && \
mv /build/etc/pritunl.conf /build/etc/pritunl.conf.orig && \
ln -s /data/pritunl/pritunl.conf /build/etc/pritunl.conf && \
cd - && \
rm -rf /build/include /build/share /build/build && \
find /build/ -depth \( \( -type d -a \( -name test -o -name tests \) \) -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \) -exec rm -rf '{}' + && \
mkdir -p /build/run/systemd && \
echo 'docker' > /build/run/systemd/container && \
curl -sL --retry 3 --insecure "https://raw.githubusercontent.com/fscm/tools/master/lddcp/lddcp" -o ./lddcp && \
chmod +x ./lddcp && \
./lddcp $(for f in `find /build/ -type f -executable`; do echo "-p $f "; done) $(for f in `find /lib/x86_64-linux-gnu/ \( -name 'libnss*' -o -name 'libresolv*' \)`; do echo "-l $f "; done) -d /build && \
curl -sL --retry 3 --insecure "https://busybox.net/downloads/binaries/${BUSYBOX_VERSION}-i686/busybox" -o /build/bin/busybox && \
chmod +x /build/bin/busybox && \
for p in [ [[ basename cat cp date diff du echo env free grep ip killall less ln ls mkdir mknod mktemp more mv ping ps rm sed sort stty sysctl tr; do ln -s busybox /build/bin/${p}; done && \
ln -s /bin/ip /build/sbin/ip && \
chmod a+x /usr/local/bin/* && \
cp /usr/local/bin/* /build/bin/



FROM scratch

LABEL \
maintainer="Frederico Martins <https://hub.docker.com/u/fscm/>"

EXPOSE \
80 \
443 \
1194 \
1194/udp

COPY --from=build \
/build .

VOLUME ["/data/pritunl"]

ENTRYPOINT ["/bin/run"]

CMD ["help"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016-2019, Frederico Martins

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.
Loading

0 comments on commit d1b53db

Please sign in to comment.