【弃坑】使用Docker打包shadowsocks-libev镜像

介绍

记录一下使用Dockerfile制作shadowsocks-libev镜像的过程

  • 基于Alpine-3.8和shadowsocks-libev-v3.2.3制作
  • 参考shadowsocks-libev项目上面的Dockerfile

以下是Dockerfile内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# README
# /* BUILD IMAGE */
# dokcer image build -t shadowsocks-libev:v3.2.3 .

# /* RUN CONATIANER */
# docker container run -d -e SERVER_PORT=111 -e PASSWORD='password' -e METHOD='aes-256-gcm' --net host --name ss-libev-port111 shadowsocks-libev:v3.2-alpine3.8

# /* SS-SERVER HELP */
# shadowsocks-libev 3.2.3
#
# maintained by Max Lv <max.c.lv@gmail.com> and Linus Yang <laokongzi@gmail.com>
#
# usage:
#
# ss-server
#
# -s <server_host> Host name or IP address of your remote server.
# -p <server_port> Port number of your remote server.
# -l <local_port> Port number of your local server.
# -k <password> Password of your remote server.
# -m <encrypt_method> Encrypt method: rc4-md5,
# aes-128-gcm, aes-192-gcm, aes-256-gcm,
# aes-128-cfb, aes-192-cfb, aes-256-cfb,
# aes-128-ctr, aes-192-ctr, aes-256-ctr,
# camellia-128-cfb, camellia-192-cfb,
# camellia-256-cfb, bf-cfb,
# chacha20-ietf-poly1305,
# xchacha20-ietf-poly1305,
# salsa20, chacha20 and chacha20-ietf.
# The default cipher is chacha20-ietf-poly1305.
#
# [-a <user>] Run as another user.
# [-f <pid_file>] The file path to store pid.
# [-t <timeout>] Socket timeout in seconds.
# [-c <config_file>] The path to config file.
# [-n <number>] Max number of open files.
# [-i <interface>] Network interface to bind.
# [-b <local_address>] Local address to bind.
#
# [-u] Enable UDP relay.
# [-U] Enable UDP relay and disable TCP relay.
# [-6] Resovle hostname to IPv6 address first.
#
# [-d <addr>] Name servers for internal DNS resolver.
# [--reuse-port] Enable port reuse.
# [--fast-open] Enable TCP fast open.
# with Linux kernel > 3.7.0.
# [--acl <acl_file>] Path to ACL (Access Control List).
# [--manager-address <addr>] UNIX domain socket address.
# [--mtu <MTU>] MTU of your network interface.
# [--mptcp] Enable Multipath TCP on MPTCP Kernel.
# [--no-delay] Enable TCP_NODELAY.
# [--key <key_in_base64>] Key of your remote server.
# [--plugin <name>] Enable SIP003 plugin. (Experimental)
# [--plugin-opts <options>] Set SIP003 plugin options. (Experimental)
#
# [-v] Verbose mode.
# [-h, --help] Print this message.

FROM alpine:3.8
ENV TZ 'Asia/Shanghai'
ENV SS_VERSION 3.2.3
ENV SS_DOWNLOAD_URL https://github.com/shadowsocks/shadowsocks-libev/releases/download/v${SS_VERSION}/shadowsocks-libev-${SS_VERSION}.tar.gz
RUN apk upgrade \
&& apk add bash tzdata libsodium rng-tools \
&& apk add --virtual .build-deps \
autoconf \
automake \
xmlto \
build-base \
curl \
c-ares-dev \
libev-dev \
libtool \
linux-headers \
udns-dev \
libsodium-dev \
mbedtls-dev \
pcre-dev \
udns-dev \
tar \
git \
&& wget -q -O - $SS_DOWNLOAD_URL | tar xz \
&& (cd shadowsocks-libev-${SS_VERSION} \
&& ./configure --prefix=/usr --disable-documentation \
&& make install) \
&& ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& apk del .build-deps \
&& rm -rf shadowsocks-libev-${SS_VERSION} \
/var/cache/apk/* \
&& apk add --no-cache \
rng-tools \
$(scanelf --needed --nobanner /usr/bin/ss-* \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u)

CMD ["/usr/bin/ss-server"]