LoginSignup
2
0

More than 3 years have passed since last update.

Drone CI Open Source Edition のコンテナイメージをビルドする

Last updated at Posted at 2019-10-26

Docker Hub に用意されているものは Enterprise Edition のため、一定規模以上での無償利用にはビルド数に制限がある。機能は少ないが制限なしで使える Open Source Edition をコンテナで動作させる。

環境

ビルド手順

Drone Server のビルド

BUILDING_OSS を参考にビルドする。

デフォルトのビルドは glibc にダイナミックリンクされるため、素の alpine 上では動作しない。そのため、-ldflags "-extldflags \"-static\"" をつけてスタティックリンクする。以下は golang コンテナで drone-server をビルドする例。

$ DRONE_VERSION=1.6.0
$ git clone -b v${DRONE_VERSION} https://github.com/drone/drone drone_${DRONE_VERSION}
$ cd drone_${DRONE_VERSION}
$ docker run -it -v `pwd`:/src golang bash
# cd /src
# go build -tags "oss nolimit" \
    -ldflags "-extldflags \"-static\"" \
    -o release/linux/amd64/drone-server \
    github.com/drone/drone/cmd/drone-server
# exit

Docker イメージ作成

Dockerfile.server.linux.amd64 を参考に Dockerfile を作成する。(Datadog は無効化したくらい。)

# docker build --rm -f docker/Dockerfile -t drone/drone .

FROM alpine:3.9 as alpine
RUN apk add -U --no-cache ca-certificates

FROM alpine:3.9
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=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ADD release/linux/amd64/drone-server /bin/
ENTRYPOINT ["/bin/drone-server"]

ビルドする。

$ docker build -t drone${DRONE_VERSION} .
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0