|
| 1 | +# Nestybox's Drone-agent Dockerfile. |
| 2 | +# |
| 3 | +# Description: |
| 4 | +# |
| 5 | +# Dockerfile to construct a system container hosting Drone-agent functionality. |
| 6 | +# The obtained image will incorporate the drone-agent binary, as well as the |
| 7 | +# Docker package required to instantiate 'slave' containers to execute continous |
| 8 | +# integration tasks. Both daemons (drone-agent and dockerd) will be managed |
| 9 | +# through supervisord process manager. |
| 10 | +# |
| 11 | +# Requirements: |
| 12 | +# |
| 13 | +# A supervisord.conf file in charge of launching dockerd & drone-agent daemons, |
| 14 | +# must be provided as part of this image compilation process. See example below: |
| 15 | +# |
| 16 | +# --- |
| 17 | +# $ cat supervisord.conf |
| 18 | +# [supervisord] |
| 19 | +# stdout_logfile=/dev/stdout |
| 20 | +# stdout_logfile_maxbytes=0 |
| 21 | +# nodaemon=true |
| 22 | +# |
| 23 | +# [program:dockerd] |
| 24 | +# command=/usr/bin/dockerd |
| 25 | +# priority=1 |
| 26 | +# autostart=true |
| 27 | +# autorestart=true |
| 28 | +# startsecs=0 |
| 29 | +# |
| 30 | +# [program:drone-agent] |
| 31 | +# command=/bin/drone-agent |
| 32 | +# priority=2 |
| 33 | +# autostart=true |
| 34 | +# autorestart=true |
| 35 | +# startsecs=0 |
| 36 | +# --- |
| 37 | +# |
| 38 | +# Container initialization: |
| 39 | +# |
| 40 | +# $ docker run --runtime=sysbox-runc \ |
| 41 | +# --env=DRONE_SERVER_HOST=my-drone.server.com:80 \ |
| 42 | +# --env=DRONE_RPC_SECRET=my-secret \ |
| 43 | +# -d --rm --name=drone nestybox/ubuntu-bionic-drone-agent |
| 44 | +# |
| 45 | +# [ refer to Drone's official documentation for more details ] |
| 46 | +# |
| 47 | + |
| 48 | + |
| 49 | +####################### |
| 50 | +# Drone compilation # |
| 51 | +####################### |
| 52 | + |
| 53 | +FROM golang:latest as golang |
| 54 | +RUN cd /root && \ |
| 55 | + git clone https://github.com/drone/drone.git && \ |
| 56 | + cd drone && \ |
| 57 | + sh scripts/build.sh |
| 58 | + |
| 59 | +RUN cd /root && \ |
| 60 | + git clone https://github.com/drone/drone-cli.git && \ |
| 61 | + cd drone-cli && \ |
| 62 | + sh .drone.sh |
| 63 | + |
| 64 | + |
| 65 | +######################## |
| 66 | +# Drone installation # |
| 67 | +######################## |
| 68 | + |
| 69 | +FROM ubuntu:bionic |
| 70 | +EXPOSE 80 443 |
| 71 | +VOLUME /data |
| 72 | + |
| 73 | +ENV GODEBUG netdns=go |
| 74 | +ENV XDG_CACHE_HOME /data |
| 75 | +ENV DRONE_DATABASE_DRIVER sqlite3 |
| 76 | +ENV DRONE_DATABASE_DATASOURCE /data/database.sqlite |
| 77 | +ENV DRONE_RUNNER_OS=linux |
| 78 | +ENV DRONE_RUNNER_ARCH=amd64 |
| 79 | +ENV DRONE_SERVER_PORT=:80 |
| 80 | +ENV DRONE_SERVER_HOST=localhost |
| 81 | +ENV DRONE_DATADOG_ENABLED=true |
| 82 | +ENV DRONE_DATADOG_ENDPOINT=https://stats.drone.ci/api/v1/series |
| 83 | + |
| 84 | + |
| 85 | +RUN apt-get update && \ |
| 86 | + apt-get install -y --no-install-recommends ca-certificates && \ |
| 87 | + rm -rf /var/lib/apt/lists/* |
| 88 | + |
| 89 | +# Add previously built drone binaries. |
| 90 | +COPY --from=golang /root/drone/release/linux/drone-agent /bin/ |
| 91 | +COPY --from=golang /root/drone-cli/release/linux/amd64/drone /bin/ |
| 92 | + |
| 93 | + |
| 94 | +######################### |
| 95 | +# Docker installation # |
| 96 | +######################### |
| 97 | + |
| 98 | +RUN apt-get update && \ |
| 99 | + apt-get install -y --no-install-recommends apt-transport-https \ |
| 100 | + ca-certificates curl gnupg-agent software-properties-common && \ |
| 101 | + rm -rf /var/lib/apt/lists/* && \ |
| 102 | + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ |
| 103 | + apt-key fingerprint 0EBFCD88 |
| 104 | + |
| 105 | +RUN add-apt-repository \ |
| 106 | + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ |
| 107 | + $(lsb_release -cs) \ |
| 108 | + stable" |
| 109 | + |
| 110 | +RUN apt-get update && \ |
| 111 | + apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io && \ |
| 112 | + rm -rf /var/lib/apt/lists/* |
| 113 | + |
| 114 | + |
| 115 | +############################## |
| 116 | +# Supervisord installation # |
| 117 | +############################## |
| 118 | + |
| 119 | +RUN apt-get update && apt-get install -y --no-install-recommends supervisor && \ |
| 120 | + rm -rf /var/lib/apt/lists/* |
| 121 | + |
| 122 | +RUN mkdir -p /var/log/supervisor |
| 123 | +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
| 124 | +CMD ["/usr/bin/supervisord"] |
0 commit comments