Skip to content

Commit 5b880e2

Browse files
committed
Merge branch 'patch-1' into 'master'
Optimize the Dockerfile. Handle ovpn not initialized See merge request ix.ai/openvpn!22
2 parents 31db31b + 18bbeeb commit 5b880e2

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

Dockerfile

+23-19
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,30 @@ FROM alpine:latest
44
LABEL maintainer="[email protected]" \
55
ai.ix.repository="ix.ai/openvpn"
66

7+
ADD bin/* /usr/local/bin/
8+
9+
# Add support for OTP authentication using a PAM module
10+
ADD ./otp/openvpn /etc/pam.d/
11+
712
# Testing: pamtester
8-
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories && \
9-
apk --no-cache upgrade && \
10-
apk add --no-cache --update openvpn \
11-
dnsmasq \
12-
iptables \
13-
bash \
14-
easy-rsa \
15-
openvpn-auth-pam \
16-
google-authenticator \
17-
pamtester \
18-
libqrencode && \
19-
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
20-
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
13+
RUN set -eux; \
14+
\
15+
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories; \
16+
apk --no-cache upgrade; \
17+
apk add --no-cache --update \
18+
openvpn \
19+
dnsmasq \
20+
iptables \
21+
bash \
22+
easy-rsa \
23+
openvpn-auth-pam \
24+
google-authenticator \
25+
pamtester \
26+
libqrencode \
27+
; \
28+
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin; \
29+
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*; \
30+
chmod a+x /usr/local/bin/*
2131

2232
# Needed by scripts
2333
ENV OPENVPN /etc/openvpn
@@ -34,9 +44,3 @@ VOLUME ["/etc/openvpn"]
3444
EXPOSE 1194/udp
3545

3646
CMD ["ovpn_run"]
37-
38-
ADD ./bin /usr/local/bin
39-
RUN chmod a+x /usr/local/bin/*
40-
41-
# Add support for OTP authentication using a PAM module
42-
ADD ./otp/openvpn /etc/pam.d/

bin/ovpn_run

+8-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ function startDnsmasq() {
8181

8282
addArg "--config" "$OPENVPN/openvpn.conf"
8383

84-
source "$OPENVPN/ovpn_env.sh"
84+
if [ ! -f "${OPENVPN}/ovpn_env.sh" ]; then
85+
echo "Can't find ${OPENVPN}/ovpn_env.sh."
86+
echo "Please make sure that OpenVPN is initialized and the proper volume is mounted!"
87+
echo "For details see https://ix.ai/openvpn/-/blob/master/README.md#quick-start"
88+
exit 1
89+
fi
90+
91+
source "${OPENVPN}/ovpn_env.sh"
8592

8693
mkdir -p /dev/net
8794
if [ ! -c /dev/net/tun ]; then

0 commit comments

Comments
 (0)