forked from sslavvvvvvv/proxypool-okteto
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
132 lines (111 loc) · 3.6 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
##########################################
# 构建可执行二进制文件 #
##########################################
# 指定构建的基础镜像
FROM golang:alpine AS builder
# 作者描述信息
MAINTAINER danxiaonuo
# 时区设置
ARG TZ=Asia/Shanghai
ENV TZ=$TZ
# 版本号
ARG TAGS=v0.7.3
ENV TAGS=$TAGS
# 镜像变量
ARG DOCKER_IMAGE=danxiaonuo/proxypool
ENV DOCKER_IMAGE=$DOCKER_IMAGE
ARG DOCKER_IMAGE_OS=golang
ENV DOCKER_IMAGE_OS=$DOCKER_IMAGE_OS
ARG DOCKER_IMAGE_TAG=alpine
ENV DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG
ARG BUILD_DATE
ENV BUILD_DATE=$BUILD_DATE
ARG VCS_REF
ENV VCS_REF=$VCS_REF
ARG BUILD_DEPS="\
git \
make"
ENV BUILD_DEPS=$BUILD_DEPS
# 修改源地址
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# ***** 安装依赖 *****
RUN set -eux \
# 更新源地址
&& apk update \
# 更新系统并更新系统软件
&& apk upgrade && apk upgrade \
&& apk add -U --update $BUILD_DEPS \
# 更新时区
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
# 更新时间
&& echo ${TZ} > /etc/timezone
# 运行工作目录
WORKDIR /build
# 克隆源码运行安装
RUN git clone --depth=1 -b ${TAGS} --progress https://github.com/Sansui233/proxypool.git /src && \
cd /src && go mod download && make docker
# ##############################################################################
##########################################
# 构建基础镜像 #
##########################################
#
# 指定创建的基础镜像
FROM alpine:latest
# 作者描述信息
MAINTAINER danxiaonuo
# 时区设置
ARG TZ=Asia/Shanghai
ENV TZ=$TZ
ARG PKG_DEPS="\
tzdata \
ca-certificates"
ENV PKG_DEPS=$PKG_DEPS
# dumb-init
# https://github.com/Yelp/dumb-init
ARG DUMBINIT_VERSION=1.2.5
ENV DUMBINIT_VERSION=$DUMBINIT_VERSION
# http://label-schema.org/rc1/
LABEL maintainer="danxiaonuo <[email protected]>" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="$DOCKER_IMAGE" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://github.com/$DOCKER_IMAGE" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/$DOCKER_IMAGE" \
versions.dumb-init=${DUMBINIT_VERSION}
# 修改源地址
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# ***** 安装依赖 *****
RUN set -eux \
# 更新源地址
&& apk update \
# 更新系统并更新系统软件
&& apk upgrade && apk upgrade \
&& apk add -U --update $PKG_DEPS \
# 更新时区
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
# 更新时间
&& echo ${TZ} > /etc/timezone
# 工作目录
WORKDIR /proxypool-src
# 拷贝proxypool
COPY --from=0 /src/bin/proxypool-docker /proxypool-src/proxypool
COPY --from=0 /src/assets /proxypool-src/assets
# 授予文件权限
RUN set -eux && \
mkdir -p /proxypool-src/conf/proxypool && \
chmod +x /proxypool-src/proxypool && \
chmod -R 775 /proxypool-src
# 增加配置文件
COPY ./conf/proxypool/config.yaml /proxypool-src/conf/proxypool/config.yaml
COPY ./conf/proxypool/source.yaml /proxypool-src/conf/proxypool/source.yaml
# 安装dumb-init
RUN set -eux \
&& wget --no-check-certificate https://github.com/Yelp/dumb-init/releases/download/v${DUMBINIT_VERSION}/dumb-init_${DUMBINIT_VERSION}_x86_64 -O /usr/bin/dumb-init \
&& chmod +x /usr/bin/dumb-init
# 容器信号处理
STOPSIGNAL SIGQUIT
# 入口
ENTRYPOINT ["dumb-init"]
# 运行proxypool
CMD ["/proxypool-src/proxypool", "-c", "/proxypool-src/conf/proxypool/config.yaml", "-d"]