-
Notifications
You must be signed in to change notification settings - Fork 759
/
Dockerfile
41 lines (33 loc) · 1.41 KB
/
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
FROM alpine:latest
ARG APP_ROOT=/app/manba
ARG EXEC_NAME=manba-proxy
ARG UID=2019
ARG CMD_NAME=demo
ENV CURRENT_EXEC_PATH=${APP_ROOT}/${EXEC_NAME}
ENV PATH=${APP_ROOT}:$PATH
WORKDIR ${APP_ROOT}
ADD dist ${APP_ROOT}
# Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf,
# but Golang relies on /etc/nsswitch.conf to check the order of DNS resolving
# (see https://github.com/golang/go/commit/9dee7771f561cf6aee081c0af6658cc81fac3918)
# To fix this we just create /etc/nsswitch.conf and add the following line:
# hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
RUN MAIN_VERSION=$(cat /etc/alpine-release | cut -d '.' -f 0-2) \
&& mv /etc/apk/repositories /etc/apk/repositories-bak \
&& { \
echo "https://mirrors.aliyun.com/alpine/v${MAIN_VERSION}/main"; \
echo "https://mirrors.aliyun.com/alpine/v${MAIN_VERSION}/community"; \
} >> /etc/apk/repositories \
&& apk add --update --no-cache libcap \
&& addgroup -g ${UID} -S manba \
&& adduser -u ${UID} -S manba -G manba \
&& mkdir -p ${APP_ROOT}/plugins \
&& chown -R manba:manba ./ \
&& if [ -e ${CURRENT_EXEC_PATH} ]; then \
setcap CAP_NET_BIND_SERVICE=+eip ${CURRENT_EXEC_PATH}; \
fi \
&& echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf \
&& echo -n ${CMD_NAME} > cmd
USER manba
EXPOSE 80 2379 9092 9093
ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]