Add scripting to run drone-server on Cloudron

Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
Felix Bartels 2020-06-05 22:25:57 +02:00
commit ab399ce040
5 changed files with 115 additions and 0 deletions

11
CloudronManifest.json Normal file
View file

@ -0,0 +1,11 @@
{
"version": "0.0.1",
"id": "com.github.drone",
"healthCheckPath": "/",
"httpPort": 8000,
"addons": {
"localstorage": {},
"postgresql": {}
},
"manifestVersion": 2
}

26
Dockerfile Normal file
View file

@ -0,0 +1,26 @@
FROM drone/drone:1.7.0 as drone
FROM cloudron/base:2.0.0@sha256:f9fea80513aa7c92fe2e7bf3978b54c8ac5222f47a9a32a7f8833edf0eb5a4f4
EXPOSE 8000
# add supervisor configs
RUN sed -e 's,^logfile=.*$,logfile=/run/supervisord.log,' -i /etc/supervisor/supervisord.conf
COPY supervisor-drone-server.conf /etc/supervisor/conf.d/
ENV \
XDG_CACHE_HOME=/app/data \
DRONE_SERVER_PROTO=https \
DRONE_DATABASE_DRIVER=postgres \
DRONE_RUNNER_OS=linux \
DRONE_RUNNER_ARCH=amd64 \
DRONE_SERVER_PORT=:8000 \
DRONE_DATADOG_ENABLED=false
COPY --from=drone /bin/drone-server /bin
COPY start.sh /app/pkg/
WORKDIR /app/data
CMD [ "/app/pkg/start.sh" ]

38
Makefile Normal file
View file

@ -0,0 +1,38 @@
CLOUDRON_APP ?= drone
CLOUDRON_ID := $(shell jq -r .id CloudronManifest.json)
DOCKER_REPO ?= fbartels
.PHONY: default
default: build update
.PHONY: init
init:
cloudron init
.PHONY: build
build:
cloudron build --set-repository $(DOCKER_REPO)/$(CLOUDRON_ID)
.PHONY: update
update: build
cloudron update --app ${CLOUDRON_APP}
.PHONY: install
install: build
cloudron install --location ${CLOUDRON_APP}
.PHONY: uninstall
uninstall:
cloudron uninstall --app ${CLOUDRON_APP}
.PHONY: install-debug
install-debug:
cloudron install --location ${CLOUDRON_APP} --debug
.PHONY: exec
exec:
cloudron exec --app ${CLOUDRON_APP}
.PHONY: logs
logs:
cloudron logs -f --app ${CLOUDRON_APP}

30
start.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
set -x
random_string() {
LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c32
}
if [ ! -e /app/data/.env ]; then
cat <<-EOF > "/app/data/.env"
# Custom configuration for drone-server
DRONE_GITEA_SERVER=git.9wd.eu
DRONE_GITEA_CLIENT_ID=xxx
DRONE_GITEA_CLIENT_SECRET=xxx
DRONE_RPC_SECRET=$(random_string)
DRONE_DATABASE_SECRET=$(random_string)
DRONE_SERVER_HOST=$CLOUDRON_APP_DOMAIN
DRONE_DATABASE_DATASOURCE=postgres://$CLOUDRON_POSTGRESQL_USERNAME:$CLOUDRON_POSTGRESQL_PASSWORD@$CLOUDRON_POSTGRESQL_HOST:$CLOUDRON_POSTGRESQL_PORT/$CLOUDRON_POSTGRESQL_DATABASE?sslmode=disable
EOF
fi
# export all values from ".env"
set -a
. /app/data/.env
set +x
echo "=> Ensure permissions"
chown -R cloudron:cloudron /run /app/data
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i drone-server

View file

@ -0,0 +1,10 @@
[program:drone-server]
command=/bin/drone-server
directory=/app/data
user=cloudron
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0