-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (51 loc) · 1.76 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (51 loc) · 1.76 KB
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
FROM golang:1.18-alpine AS build
WORKDIR $GOPATH/src
# 安装git
ENV ALPINE_MIRROR=mirrors.aliyun.com
RUN echo https://mirrors.aliyun.com/alpine/v3.16/main/ > /etc/apk/repositories
RUN apk add --no-cache git gcc libpcap-dev build-base
# 克隆minlib代码
RUN git clone https://x-access-token:JTRUGsneYyk53PuYxmdt@git.sscfs.cn/pkusz-future-network-lab/common/minlib.git
# 切换minlib分支
WORKDIR $GOPATH/src/minlib
RUN git checkout parallel-mir
# 设置 GOPROXY 代理
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn
# 安装minlib依赖
RUN go mod download
# 克隆mir-go代码
WORKDIR $GOPATH/src
RUN git clone https://x-access-token:JTRUGsneYyk53PuYxmdt@git.sscfs.cn/pkusz-future-network-lab/mir/mir-go.git
# 切换mir-go分支
WORKDIR $GOPATH/src/mir-go
RUN git checkout parallel-mir
# 安装mir-go依赖
RUN go mod tidy
# 编译mir
WORKDIR $GOPATH/src/mir-go/daemon/mircmd/
RUN go install ./mir
RUN go install ./mird
RUN go install ./mirgen
# 编译mirc
WORKDIR $GOPATH/src/mir-go/daemon/mgmt
RUN go install ./mirc
# 拷贝可执行文件到镜像里
FROM alpine
ENV ALPINE_MIRROR=mirrors.aliyun.com
RUN echo https://mirrors.aliyun.com/alpine/v3.16/main/ > /etc/apk/repositories
RUN apk add --no-cache libpcap-dev bash
WORKDIR /root/
RUN mkdir -p /usr/local/etc \
&& mkdir -p /usr/local/etc/mir \
&& mkdir -p /usr/local/etc/mir/passwd
COPY --from=build /go/bin/mir /usr/local/bin/
COPY --from=build /go/bin/mird /usr/local/bin/
COPY --from=build /go/bin/mirgen /usr/local/bin/
COPY --from=build /go/bin/mirc /usr/local/bin/
COPY --from=build /go/src/mir-go/mirconf.ini .
RUN cp mirconf.ini /usr/local/etc/mir/
COPY --from=build /go/src/mir-go/defaultRoute.xml .
RUN cp defaultRoute.xml /usr/local/etc/mir/
RUN touch /tmp/mir.sock
RUN echo "success"