Skip to content

Commit 18b9050

Browse files
Merge pull request #71 from leojonathanoh/enhancement/add-openvpn-2.6.14-variants
Enhancement: Add openvpn 2.6.14 variants
2 parents 9d450c6 + 0b6634c commit 18b9050

File tree

9 files changed

+701
-25
lines changed

9 files changed

+701
-25
lines changed

.github/workflows/ci-master-pr.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: |
3434
git diff --exit-code
3535
36-
build-2-6-12:
36+
build-2-6-14:
3737
runs-on: ubuntu-latest
3838
steps:
3939
- name: Checkout
@@ -64,9 +64,9 @@ jobs:
6464
uses: actions/cache@v4
6565
with:
6666
path: /tmp/.buildx-cache
67-
key: ${{ runner.os }}-buildx-2.6.12-${{ github.sha }}
67+
key: ${{ runner.os }}-buildx-2.6.14-${{ github.sha }}
6868
restore-keys: |
69-
${{ runner.os }}-buildx-2.6.12-
69+
${{ runner.os }}-buildx-2.6.14-
7070
${{ runner.os }}-buildx-
7171
7272
- name: Login to Docker Hub registry
@@ -79,7 +79,7 @@ jobs:
7979

8080
# This step generates the docker tags
8181
- name: Prepare
82-
id: prep-2-6-12-alpine-edge
82+
id: prep-2-6-14-alpine-3-22
8383
run: |
8484
set -e
8585
@@ -92,7 +92,7 @@ jobs:
9292
# Generate docker image tags
9393
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
9494
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
95-
VARIANT="2.6.12-alpine-edge"
95+
VARIANT="2.6.14-alpine-3.22"
9696
REF_VARIANT="${REF}-${VARIANT}"
9797
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
9898
@@ -102,45 +102,45 @@ jobs:
102102
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
103103
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
104104
105-
- name: 2.6.12-alpine-edge - Build (PRs)
105+
- name: 2.6.14-alpine-3.22 - Build (PRs)
106106
# Run only on pull requests
107107
if: github.event_name == 'pull_request'
108108
uses: docker/build-push-action@v5
109109
with:
110-
context: variants/2.6.12-alpine-edge
110+
context: variants/2.6.14-alpine-3.22
111111
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
112112
push: false
113113
tags: |
114-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.REF_VARIANT }}
115-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.REF_SHA_VARIANT }}
114+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.REF_VARIANT }}
115+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.REF_SHA_VARIANT }}
116116
cache-from: type=local,src=/tmp/.buildx-cache
117117
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
118118

119-
- name: 2.6.12-alpine-edge - Build and push (master)
119+
- name: 2.6.14-alpine-3.22 - Build and push (master)
120120
# Run only on master
121121
if: github.ref == 'refs/heads/master'
122122
uses: docker/build-push-action@v5
123123
with:
124-
context: variants/2.6.12-alpine-edge
124+
context: variants/2.6.14-alpine-3.22
125125
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
126126
push: true
127127
tags: |
128-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.REF_VARIANT }}
129-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.REF_SHA_VARIANT }}
128+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.REF_VARIANT }}
129+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.REF_SHA_VARIANT }}
130130
cache-from: type=local,src=/tmp/.buildx-cache
131131
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
132132

133-
- name: 2.6.12-alpine-edge - Build and push (release)
133+
- name: 2.6.14-alpine-3.22 - Build and push (release)
134134
if: startsWith(github.ref, 'refs/tags/')
135135
uses: docker/build-push-action@v5
136136
with:
137-
context: variants/2.6.12-alpine-edge
137+
context: variants/2.6.14-alpine-3.22
138138
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
139139
push: true
140140
tags: |
141-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.VARIANT }}
142-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.REF_VARIANT }}
143-
${{ github.repository }}:${{ steps.prep-2-6-12-alpine-edge.outputs.REF_SHA_VARIANT }}
141+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.VARIANT }}
142+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.REF_VARIANT }}
143+
${{ github.repository }}:${{ steps.prep-2-6-14-alpine-3-22.outputs.REF_SHA_VARIANT }}
144144
${{ github.repository }}:latest
145145
cache-from: type=local,src=/tmp/.buildx-cache
146146
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
@@ -1323,7 +1323,7 @@ jobs:
13231323
13241324
update-draft-release:
13251325
needs:
1326-
- build-2-6-12
1326+
- build-2-6-14
13271327
- build-2-6-11
13281328
- build-2-5-10
13291329
- build-2-4-12
@@ -1344,7 +1344,7 @@ jobs:
13441344

13451345
publish-draft-release:
13461346
needs:
1347-
- build-2-6-12
1347+
- build-2-6-14
13481348
- build-2-6-11
13491349
- build-2-5-10
13501350
- build-2-4-12
@@ -1367,7 +1367,7 @@ jobs:
13671367

13681368
update-dockerhub-description:
13691369
needs:
1370-
- build-2-6-12
1370+
- build-2-6-14
13711371
- build-2-6-11
13721372
- build-2-5-10
13731373
- build-2-4-12

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Dockerized `openvpn`.
1212

1313
| Tag | Dockerfile Build Context |
1414
|:-------:|:---------:|
15-
| `:2.6.12-alpine-edge`, `:latest` | [View](variants/2.6.12-alpine-edge) |
15+
| `:2.6.14-alpine-3.22`, `:latest` | [View](variants/2.6.14-alpine-3.22) |
1616
| `:2.6.11-alpine-3.18` | [View](variants/2.6.11-alpine-3.18) |
1717
| `:2.5.10-alpine-3.17` | [View](variants/2.5.10-alpine-3.17) |
1818
| `:2.4.12-alpine-3.12` | [View](variants/2.4.12-alpine-3.12) |
@@ -38,7 +38,7 @@ It is assumed that you have knowledge of configuring `openvpn`. If needed, refer
3838
To run the image, at the least you should mount a `/etc/openvpn/server.conf`, which may be a unified openvpn profile (see INLINE FILE SUPPORT section in the [openvpn manual](https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage)).
3939

4040
```sh
41-
docker run --rm -it --cap-add NET_ADMIN -v /path/to/server.conf:/etc/openvpn/server.conf theohbrothers/docker-openvpn:2.6.12-alpine-edge
41+
docker run --rm -it --cap-add NET_ADMIN -v /path/to/server.conf:/etc/openvpn/server.conf theohbrothers/docker-openvpn:2.6.14-alpine-3.22
4242
```
4343

4444
## Environment variables

generate/definitions/VARIANTS.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
$local:VARIANTS_MATRIX = @(
33
@{
44
package = 'openvpn'
5-
package_version = '2.6.12'
5+
package_version = '2.6.14'
66
distro = 'alpine'
7-
distro_version = 'edge'
7+
distro_version = '3.22'
88
subvariants = @(
99
@{ components = @() }
1010
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM alpine:3.22
2+
3+
RUN set -eux; \
4+
apk add --no-cache openvpn~=2.6.14 iptables; \
5+
# Workaround openvpn --version exiting with non-zero exit code on openvpn <= 2.4.x
6+
openvpn --version | grep -A100 -B100 2.6.14
7+
8+
COPY docker-entrypoint.sh /docker-entrypoint.sh
9+
RUN chmod +x /docker-entrypoint.sh
10+
11+
ENTRYPOINT ["/docker-entrypoint.sh"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: '2.1'
2+
services:
3+
openvpn-server:
4+
build:
5+
dockerfile: Dockerfile
6+
context: .
7+
environment:
8+
- OPENVPN_CONFIG_FILE=/etc/openvpn/server.conf
9+
- NAT_MASQUERADE=1
10+
# - CUSTOM_FIREWALL_SCRIPT=/etc/openvpn/firewall.sh
11+
volumes:
12+
- ./openvpn/server.conf:/etc/openvpn/server.conf
13+
# - ./openvpn/firewall.sh:/etc/openvpn/firewall.sh
14+
ports:
15+
- 1194:1194/udp
16+
cap_add:
17+
- NET_ADMIN
18+
# sysctls for the container if it is not set on the host. See: https://docs.docker.com/compose/compose-file/compose-file-v2/#sysctls
19+
sysctls:
20+
- net.ipv4.conf.all.forwarding=1
21+
# - net.ipv6.conf.all.disable_ipv6=0
22+
# - net.ipv6.conf.default.forwarding=1
23+
# - net.ipv6.conf.all.forwarding=1
24+
restart: unless-stopped
25+
26+
openvpn-client:
27+
build:
28+
dockerfile: Dockerfile
29+
context: .
30+
environment:
31+
- OPENVPN_CONFIG_FILE=/etc/openvpn/client.conf
32+
- NAT_MASQUERADE=0
33+
# - CUSTOM_FIREWALL_SCRIPT=/etc/openvpn/firewall.sh
34+
volumes:
35+
- ./openvpn/client.conf:/etc/openvpn/client.conf
36+
# - ./openvpn/firewall.sh:/etc/openvpn/firewall.sh
37+
cap_add:
38+
- NET_ADMIN
39+
# sysctls for the container if it is not set on the host. See: https://docs.docker.com/compose/compose-file/compose-file-v2/#sysctls
40+
sysctls:
41+
- net.ipv4.conf.all.forwarding=1
42+
# - net.ipv6.conf.all.disable_ipv6=0
43+
# - net.ipv6.conf.default.forwarding=1
44+
# - net.ipv6.conf.all.forwarding=1
45+
restart: unless-stopped
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
# Env vars
5+
OPENVPN_CONFIG_FILE=${OPENVPN_CONFIG_FILE:-/etc/openvpn/server.conf}
6+
OPENVPN_SERVER_CONFIG_FILE=${OPENVPN_SERVER_CONFIG_FILE:-} # Deprecated. For backward compatibility
7+
OPENVPN_ROUTES=${OPENVPN_ROUTES:-}
8+
NAT=${NAT:-1}
9+
NAT_INTERFACE=${NAT_INTERFACE:-eth0}
10+
NAT_MASQUERADE=${NAT_MASQUERADE:-1}
11+
CUSTOM_FIREWALL_SCRIPT=${CUSTOM_FIREWALL_SCRIPT:-/etc/openvpn/firewall.sh}
12+
13+
# Normalization
14+
if [ -n "$OPENVPN_SERVER_CONFIG_FILE" ]; then
15+
echo "Warning: OPENVPN_SERVER_CONFIG_FILE is deprecated. Use OPENVPN_CONFIG_FILE instead."
16+
OPENVPN_CONFIG_FILE="$OPENVPN_SERVER_CONFIG_FILE"
17+
fi
18+
19+
# If no args are passed, run the entrypoint. If a flag is passed, run openvpn directly. Else, run the passed command
20+
if [ "$#" -eq 0 ]; then
21+
# Provision
22+
echo "Provisioning tun device"
23+
mkdir -p /dev/net
24+
if [ ! -c /dev/net/tun ]; then
25+
mknod /dev/net/tun c 10 200
26+
fi
27+
if [ -f "$CUSTOM_FIREWALL_SCRIPT" ]; then
28+
echo "Executing custom firewall script: $CUSTOM_FIREWALL_SCRIPT"
29+
. "$CUSTOM_FIREWALL_SCRIPT"
30+
else
31+
echo "Not executing custom firewall script $CUSTOM_FIREWALL_SCRIPT because it does not exist"
32+
fi
33+
if [ "$NAT" = 1 ]; then
34+
echo "NAT is enabled"
35+
echo "Provisioning NAT iptables rules"
36+
echo "NAT_INTERFACE: $NAT_INTERFACE"
37+
if [ "$NAT_MASQUERADE" = 1 ]; then
38+
echo "NAT_MASQUERADE is enabled"
39+
iptables -t nat -C POSTROUTING -o "$NAT_INTERFACE" -j MASQUERADE > dev/null 2>&1 || iptables -t nat -A POSTROUTING -o "$NAT_INTERFACE" -j MASQUERADE
40+
if [ -n "$OPENVPN_ROUTES" ]; then
41+
echo "Provisioning NAT iptables rules for OPENVPN_ROUTES=$OPENVPN_ROUTES"
42+
for r in $OPENVPN_ROUTES; do
43+
iptables -t nat -C POSTROUTING -s "$r" -o "$NAT_INTERFACE" -j MASQUERADE > dev/null 2>&1 || iptables -t nat -A POSTROUTING -s "$r" -o "$NAT_INTERFACE" -j MASQUERADE
44+
done
45+
else
46+
echo "Not provisioning route iptables rules because OPENVPN_ROUTES is empty"
47+
fi
48+
else
49+
echo "Not provisioning NAT iptables rules because NAT_MASQUERADE is disabled."
50+
fi
51+
else
52+
echo "NAT is disabled."
53+
echo "Not adding NAT iptables rules"
54+
fi
55+
56+
echo "Listing iptables rules:"
57+
iptables -L -nv
58+
echo "Listing iptables NAT rules:"
59+
iptables -L -nv -t nat
60+
61+
# Generate the command line. openvpn man: https://openvpn.net/community-resources/reference-manual-for-openvpn-2-4/
62+
set openvpn --cd /etc/openvpn --config "$OPENVPN_CONFIG_FILE"
63+
echo "openvpn command line: $@"
64+
exec "$@"
65+
elif [ "$#" -gt 0 ] && [ "${1#-}" != "$1" ]; then
66+
echo "openvpn command line: $@"
67+
exec openvpn "$@"
68+
fi
69+
70+
exec "$@"

0 commit comments

Comments
 (0)