-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
36 lines (32 loc) · 986 Bytes
/
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
# 第一个阶段:编译 Go 程序
FROM golang:alpine AS builder
WORKDIR $GOPATH/src/aria2-ext
# 将代码加入到镜像中
ADD . ./
# 设置交叉编译环境
RUN apk add build-base
ENV CGO_ENABLED=1
ENV GOOS=linux
ENV GOARCH=amd64
ENV GO111MODULE=on
ENV GOPROXY="https://goproxy.io"
# 编译程序
RUN go build -o aria2-ext . && \
go build -o plugin-rss.so -buildmode=plugin ./plugin/default/RssPlugin.go
# 第二个阶段:运行程序
FROM alpine:latest
ENV ARIA2_PROTOCOL=http \
ARIA2_HOST=127.0.0.1 \
ARIA2_SECRET=P3TERX \
ARIA2_PORT=6800 \
ARIA2_PATH=/downloads \
ARIA2_PLUGINS=/plugins/ \
ARIA2_SKIP_BANNER=false \
ARIA2_STARTUP=false \
ARIA2_DB=/config/data.db
# 创建数据库文件,防止运行报错
RUN mkdir /config
# 拷贝编译好的二进制文件
COPY --from=builder /go/src/aria2-ext/aria2-ext /usr/local/bin/aria2-ext
COPY --from=builder /go/src/aria2-ext/plugin-*.so /default-plugins/
CMD ["/usr/local/bin/aria2-ext"]