services: openvpn: # noinspection ComposeUnknownKeys init: true image: local/openvpn build: dockerfile: tests/Dockerfile args: GIT_REPO: https://github.com/OpenVPN/openvpn.git GIT_BRANCH: master context: ../ cap_add: - NET_ADMIN devices: - /dev/net/tun ports: - "1194:1194/tcp" - "1194:1194/udp" - "8081:8081/tcp" volumes: - ./:/tests/:ro - ./data:/etc/openvpn #restart: always environment: UPN: "${UPN:-user@example.com}" entrypoint: - /bin/sh - -ec - |- if [ ! -f /etc/openvpn/pki/ca.crt ]; then /usr/share/easy-rsa/easyrsa init-pki nopass /usr/share/easy-rsa/easyrsa build-ca nopass /usr/share/easy-rsa/easyrsa build-server-full server nopass /usr/share/easy-rsa/easyrsa build-client-full ${UPN} nopass fi if [ ! -f /etc/openvpn/password.txt ]; then printf password > /etc/openvpn/password.txt fi if [ ! -d /etc/openvpn/client-config ]; then mkdir /etc/openvpn/client-config fi cat > "/etc/openvpn/openvpn.conf" < /etc/openvpn/env.txt'" script-security 2 status /etc/openvpn/openvpn-status.log ifconfig-pool-persist /etc/openvpn/ipp.txt tls-cert-profile preferred inactive 65 topology subnet proto tcp port 1194 user nobody group nogroup # Does not work in containers disable-dco duplicate-cn client-config-dir /etc/openvpn/client-config #management 0.0.0.0 8081 /etc/openvpn/password.txt #management-hold #management-client-auth plugin /plugin/openvpn-auth-oauth2.so tcp://0.0.0.0:8081 /etc/openvpn/password.txt reneg-sec 120 push "reneg-sec 0" auth-gen-token 300 external-auth auth-user-pass-optional EOF cat > "/etc/openvpn/${UPN}.ovpn" < $(cat /etc/openvpn/pki/private/${UPN}.key) $(openssl x509 -in /etc/openvpn/pki/issued/${UPN}.crt) $(cat /etc/openvpn/pki/ca.crt) EOF git -C /build/ log -1 exec openvpn --config "/etc/openvpn/openvpn.conf"