下载代码构建一下:
1
|
pc git clone git@github.com:harness/drone.git
|
为了让构建速度加快,我们可以适当调整 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
|
FROM golang:1.16.0-alpine3.13 AS Builder
RUN sed -i 's/https:\/\/dl-cdn.alpinelinux.org/http:\/\/mirrors.tuna.tsinghua.edu.cn/' /etc/apk/repositories && \
echo "Asia/Shanghai" > /etc/timezone
RUN apk add build-base && \
go env -w GO111MODULE=on && \
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
ENV DRONE_VERSION 2.16.0
WORKDIR /src
# Build with online code
RUN apk add curl && curl -L https://github.com/drone/drone/archive/refs/tags/v${DRONE_VERSION}.tar.gz -o v${DRONE_VERSION}.tar.gz && \
tar zxvf v${DRONE_VERSION}.tar.gz && rm v${DRONE_VERSION}.tar.gz
# OR with offline tarball
# ADD drone-1.10.1.tar.gz /src/
WORKDIR /src/drone-${DRONE_VERSION}
RUN go mod download
ENV CGO_CFLAGS="-g -O2 -Wno-return-local-addr"
RUN go build -ldflags "-extldflags \"-static\"" -tags="nolimit" github.com/drone/drone/cmd/drone-server
FROM alpine:3.13 AS Certs
RUN sed -i 's/https:\/\/dl-cdn.alpinelinux.org/http:\/\/mirrors.tuna.tsinghua.edu.cn/' /etc/apk/repositories && \
echo "Asia/Shanghai" > /etc/timezone
RUN apk add -U --no-cache ca-certificates
FROM alpine:3.13
EXPOSE 80 443
VOLUME /data
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
ENV GODEBUG netdns=go
ENV XDG_CACHE_HOME /data
ENV DRONE_DATABASE_DRIVER sqlite3
ENV DRONE_DATABASE_DATASOURCE /data/database.sqlite
ENV DRONE_RUNNER_OS=linux
ENV DRONE_RUNNER_ARCH=amd64
ENV DRONE_SERVER_PORT=:80
ENV DRONE_SERVER_HOST=localhost
ENV DRONE_DATADOG_ENABLED=true
ENV DRONE_DATADOG_ENDPOINT=https://stats.drone.ci/api/v1/series
COPY --from=Certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=Builder /src/drone-2.16.0/drone-server /bin/drone-server
ENTRYPOINT ["/bin/drone-server"]
|
构建命令:
1
|
pc docker build -t drone:2.16.0 .
|
drone-ui,需要保证 node 的版本是 14