Skip to content

Commit

Permalink
Merge pull request #4 from SloCompTech/develop
Browse files Browse the repository at this point in the history
Partial rewrite
  • Loading branch information
SloCompTech authored Jul 29, 2019
2 parents 669e1cc + 3aca21b commit 870815d
Show file tree
Hide file tree
Showing 98 changed files with 2,151 additions and 1,424 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

### 2.0.0 - Partial rewrite

- Moved `/config/hooks` to `/config/openvpn/hooks`
- Renamed `/config/openvpn/server` to `config`
- Changed base image to [slocomptech/baseimage-alpine](https://github.com/SloCompTech/docker-baseimage-alpine)
- Moved all helper scripts to `/root/usr/local/bin`
- Got rid of bash lib files
- Hiearhicaly moved all commands under the hood of `ovpn` command
- Improved backup command
- Added restore command
- Changed base image
- Added **armhf** build

### 1.0.6 - Bugfix

- Added missing `DNS` keyword to **dhcp-option** in example configs
Expand Down
104 changes: 49 additions & 55 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,70 @@ Feel free to contribute to this project.

Sections:

- [Example configs & hooks](root/defaults/example/README.md)
- [Example configs & hooks](root/defaults/example/README.md)
- [Guides](docs/README.md)
- [Helper Scripts](root/app/README.md)
- [Modules](root/defaults/module/README.md)

## Syntax

- Identation: tab (4 spaces width)
- Identation: space (2 spaces width)
- Javadoc style documentation

## Directory structure of project

```
/app # Utils (part of image)
bin # Scripts for using this image
/config # Configuration dir (all config is here, generated on container start)
openvpn # Openvpn configuration
ccd # Client config directory
client # Client configuration directory
<clientconffile>.conf # Base for building client config (all files merged)
server # Server configuration directory
<name>.conf # Server config files (all files merged)
pki
ca.crt # CA certificate
certs by serial # Certs by Serial ID
<serial-id-cert>.pem
crl.pem # CRL
dh.pem
index.txt # Database index file
issued
<name>.crt # Certificates
private # Directory with private keys
ca.key # CA secret
<name>.key # Certificate secrets
reqs # Directroy with signing requests
serial # The current serial number
ta.key # Secret for tls-auth, tls-crypt
ssl
safessl-easyrsa.cnf
vars
example # Example configs (see root/defaults/example/README.md)
config # Example client & server configs
hook # Example hook configs
module # Modules for openvpn
backup # Folder where backups are generated
example # Example configs (see root/defaults/example/README.md)
module # Modules for openvpn
openvpn # Openvpn configuration
ccd # OpenVPN client-specific configuration directory (applied when client connects)
client # Client configuration directory (for generation of .ovpn files)
<clientconffile>.conf # Base for building client config (all files merged)
config # Running config (server/client)
<name>.conf # Config files (all files merged)
hooks # Put your custom scripts in one of subfolders
auth # On authentication (needs to be enabled in config)
client-connect # Client connected
client-disconnect # Client disconnected
down # After interface is down
finish # Deinit container
init # Init container
learn-address
route-up # After routes are added
route-pre-down # Before routes are removed
up # After interface is up
tls-verify # Check certificate
auth # On authentication (needs to be enabled in config)
client-connect # Client connected
client-disconnect # Client disconnected
down # After interface is down
finish # Deinit container
init # Init container
learn-address
route-up # After routes are added
route-pre-down # Before routes are removed
up # After interface is up
tls-verify # Check certificate
system.conf # System OpenVPN config file (do not edit, unless instructed)
include-server.conf # File that includes all server configuration files (automatically generated)
donotdelete # Leave this file alone, if deleted it triggers full setup
include-conf.conf # File that includes all configuration files (automatically generated)
pki
ca.crt # CA certificate
certs by serial # Certs by Serial ID
<serial-id-cert>.pem
crl.pem # CRL
dh.pem
index.txt # Database index file
issued
<name>.crt # Certificates
private # Directory with private keys
ca.key # CA secret
<name>.key # Certificate secrets
reqs # Directroy with signing requests
secret.key # Static key (if not using real PKI)
serial # The current serial number
ta.key # Secret for tls-auth, tls-crypt
ssl
safessl-easyrsa.cnf
vars
tmp # Temporary folder
/defaults # Default configuration, which is copied into config on full setup
example # Examples
config # Example configs
hook # Example hooks
module # Modules (for example password authentication ...)
system.conf # Original server config
...
/etc # System config
cont-init.d # Scripts run before services are started
fix-attrs.d # Fix file permissions
logrotate.d # Log settings
services.d # Scripts that start services
cont-init.d # Scripts run before services are started
cont-finish.d # Scripts run after services are finished
fix-attrs.d # Fix file permissions
services.d # Scripts that start services
```

## Useful links
Expand All @@ -92,4 +86,4 @@ Sections:
- [OpenVPN docs](https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN)
- [Setup OpenVPN on alpine linux](https://wiki.alpinelinux.org/wiki/Setting_up_a_OpenVPN_server#Alternative_Certificate_Method)
- [EasyRSA](https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN)
- [EasyRSA doc](https://github.com/OpenVPN/easy-rsa/tree/master/doc)
- [EasyRSA doc](https://github.com/OpenVPN/easy-rsa/tree/master/doc)
87 changes: 49 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#
# Base image
# @see https://github.com/linuxserver/docker-baseimage-alpine
# @see https://github.com/linuxserver/docker-baseimage-alpine-python3
# @see https://github.com/SloCompTech/docker-baseimage
#
FROM lsiobase/alpine.python3:latest
FROM slocomptech/baseimage:alpine

# Build arguments
ARG BUILD_DATE
Expand All @@ -17,61 +16,73 @@ ARG VERSION
# @see http://label-schema.org/rc1/
# @see https://semver.org/
#
LABEL org.opencontainers.image.title="OpenVPN Server" \
org.label-schema.name="OpenVPN Server" \
org.opencontainers.image.description="Docker image with OpenVPN server" \
org.label-schema.description="Docker image with OpenVPN server" \
org.opencontainers.image.url="https://github.com/SloCompTech/docker-openvpn" \
org.label-schema.url="https://github.com/SloCompTech/docker-openvpn" \
org.opencontainers.image.authors="Martin Dagarin <martin.dagarin@gmail.com>" \
org.opencontainers.image.version=$VERSION \
org.label-schema.version=$VERSION \
org.opencontainers.image.revision=$VCS_REF \
org.label-schema.vcs-ref=$VCS_REF \
org.opencontainers.image.source=$VCS_SRC \
org.label-schema.vcs-url=$VCS_SRC \
org.opencontainers.image.created=$BUILD_DATE \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.schema-version="1.0"
LABEL org.opencontainers.image.title="OpenVPN Server" \
org.label-schema.name="OpenVPN Server" \
org.opencontainers.image.description="Docker image with OpenVPN server" \
org.label-schema.description="Docker image with OpenVPN server" \
org.opencontainers.image.url="https://github.com/SloCompTech/docker-openvpn" \
org.label-schema.url="https://github.com/SloCompTech/docker-openvpn" \
org.opencontainers.image.authors="Martin Dagarin <martin.dagarin@gmail.com>" \
org.opencontainers.image.version=$VERSION \
org.label-schema.version=$VERSION \
org.opencontainers.image.revision=$VCS_REF \
org.label-schema.vcs-ref=$VCS_REF \
org.opencontainers.image.source=$VCS_SRC \
org.label-schema.vcs-url=$VCS_SRC \
org.opencontainers.image.created=$BUILD_DATE \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.schema-version="1.0"


#
# Environment variables
# @see https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md
#
ENV PATH="/app/bin:$PATH" \
S6_BEHAVIOUR_IF_STAGE2_FAILS=0 \
EASYRSA=/usr/share/easy-rsa \
ENV EASYRSA=/usr/share/easy-rsa \
EASYRSA_PKI=/config/pki \
EASYRSA_VARS_FILE=/config/ssl/vars \
#EASYRSA_SSL_CONF=/config/ssl/openssl-easyrsa.cnf \
EASYRSA_SAFE_CONF=/config/ssl/safessl-easyrsa.cnf \
EASYRSA_TEMP_FILE=/config/temp \
OVPN_ROOT=/config \
OVPN_HOOKS=/config/hooks \
OVPN_RUN=system.conf
EASYRSA_TEMP_FILE=/config/tmp/temp

# Install packages
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main/" >> /etc/apk/repositories && \
apk add --no-cache \
RUN apk add --no-cache \
# Core packages
bash sudo iptables ip6tables git openvpn easy-rsa && \
bash \
easy-rsa \
iptables \
ip6tables \
openvpn \
python3 \
sudo && \
# Link easy-rsa in bin directory
ln -s ${EASYRSA}/easyrsa /usr/local/bin && \
# Link python3 also as python
ln -s /usr/bin/pip3 /usr/bin/pip && \
ln -s /usr/bin/python3 /usr/bin/python && \
# Remove any temporary files created by apk
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* && \
# Add permission for network management to user abc
echo "abc ALL=(ALL) NOPASSWD: /sbin/ip, /sbin/ip6tables, /sbin/ip6tables-compat, /sbin/ip6tables-compat-restore, /sbin/ip6tables-compat-save, /sbin/ip6tables-restore, /sbin/ip6tables-restore-translate, \
/sbin/ip6tables-save, /sbin/ip6tables-translate, /sbin/iptables, /sbin/iptables-compat, /sbin/iptables-compat-restore, /sbin/iptables-compat-save, \
/sbin/iptables-restore, /sbin/iptables-restore-translate, /sbin/iptables-save, /sbin/iptables-translate, /sbin/route" \
>> /etc/sudoers.d/abc
echo "${CONTAINER_USER} ALL=(ALL) NOPASSWD: \
/sbin/ip, \
/sbin/ip6tables, \
/sbin/ip6tables-compat, \
/sbin/ip6tables-compat-restore, \
/sbin/ip6tables-compat-save, \
/sbin/ip6tables-restore, \
/sbin/ip6tables-restore-translate, \
/sbin/ip6tables-save, \
/sbin/ip6tables-translate, \
/sbin/iptables, \
/sbin/iptables-compat, \
/sbin/iptables-compat-restore, \
/sbin/iptables-compat-save, \
/sbin/iptables-restore, \
/sbin/iptables-restore-translate, \
/sbin/iptables-save, \
/sbin/iptables-translate, \
/sbin/route" \
>> /etc/sudoers.d/${CONTAINER_USER}

# Add repo files to image
COPY root/ /

# Configure
RUN chmod +x /app/bin/* && \
chmod +x /usr/local/sbin/* && \
chmod -R 0644 /etc/logrotate.d
88 changes: 88 additions & 0 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#
# Base image
# @see https://github.com/SloCompTech/docker-baseimage
#
FROM slocomptech/baseimage:alpine-armhf

# Build arguments
ARG BUILD_DATE
ARG VCS_REF
ARG VCS_SRC
ARG VERSION

#
# Image labels
# @see https://github.com/opencontainers/image-spec/blob/master/annotations.md
# @see http://label-schema.org/rc1/
# @see https://semver.org/
#
LABEL org.opencontainers.image.title="OpenVPN Server" \
org.label-schema.name="OpenVPN Server" \
org.opencontainers.image.description="Docker image with OpenVPN server" \
org.label-schema.description="Docker image with OpenVPN server" \
org.opencontainers.image.url="https://github.com/SloCompTech/docker-openvpn" \
org.label-schema.url="https://github.com/SloCompTech/docker-openvpn" \
org.opencontainers.image.authors="Martin Dagarin <martin.dagarin@gmail.com>" \
org.opencontainers.image.version=$VERSION \
org.label-schema.version=$VERSION \
org.opencontainers.image.revision=$VCS_REF \
org.label-schema.vcs-ref=$VCS_REF \
org.opencontainers.image.source=$VCS_SRC \
org.label-schema.vcs-url=$VCS_SRC \
org.opencontainers.image.created=$BUILD_DATE \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.schema-version="1.0"


#
# Environment variables
# @see https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md
#
ENV EASYRSA=/usr/share/easy-rsa \
EASYRSA_PKI=/config/pki \
EASYRSA_VARS_FILE=/config/ssl/vars \
#EASYRSA_SSL_CONF=/config/ssl/openssl-easyrsa.cnf \
EASYRSA_SAFE_CONF=/config/ssl/safessl-easyrsa.cnf \
EASYRSA_TEMP_FILE=/config/tmp/temp

# Install packages
RUN apk add --no-cache \
# Core packages
bash \
easy-rsa \
iptables \
ip6tables \
openvpn \
python3 \
sudo && \
# Link easy-rsa in bin directory
ln -s ${EASYRSA}/easyrsa /usr/local/bin && \
# Link python3 also as python
ln -s /usr/bin/pip3 /usr/bin/pip && \
ln -s /usr/bin/python3 /usr/bin/python && \
# Remove any temporary files created by apk
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* && \
# Add permission for network management to user abc
echo "${CONTAINER_USER} ALL=(ALL) NOPASSWD: \
/sbin/ip, \
/sbin/ip6tables, \
/sbin/ip6tables-compat, \
/sbin/ip6tables-compat-restore, \
/sbin/ip6tables-compat-save, \
/sbin/ip6tables-restore, \
/sbin/ip6tables-restore-translate, \
/sbin/ip6tables-save, \
/sbin/ip6tables-translate, \
/sbin/iptables, \
/sbin/iptables-compat, \
/sbin/iptables-compat-restore, \
/sbin/iptables-compat-save, \
/sbin/iptables-restore, \
/sbin/iptables-restore-translate, \
/sbin/iptables-save, \
/sbin/iptables-translate, \
/sbin/route" \
>> /etc/sudoers.d/${CONTAINER_USER}

# Add repo files to image
COPY root/ /
Loading

0 comments on commit 870815d

Please sign in to comment.