Add helper for cli and use it to update the drone server itself (#1)

This commit is contained in:
Felix Bartels 2020-10-16 21:50:57 +00:00
parent 45a8c36530
commit 66ba25d5fe
4 changed files with 79 additions and 0 deletions

43
.drone.yml Normal file
View file

@ -0,0 +1,43 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: cloudron build & update
image: fbartels/cloudron-cli
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_USERNAME: {from_secret: DOCKER_USERNAME}
DOCKER_PASSWORD: {from_secret: DOCKER_PASSWORD}
CLOUDRON_SERVER: {from_secret: CLOUDRON_SERVER}
CLOUDRON_TOKEN: {from_secret: CLOUDRON_TOKEN}
commands:
- dockerize -wait file:///var/run/docker.sock -timeout 60s
- docker ps -a
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
- make build
- make update-ci
when:
branch:
include:
- master
services:
- name: docker
image: docker:dind
privileged: true
command: [ --storage-driver=aufs]
volumes:
- name: dockersock
path: /var/run
when:
branch:
include:
- master
volumes:
- name: dockersock
temp: {}

View file

@ -1,5 +1,7 @@
CLOUDRON_APP ?= drone
CLOUDRON_ID := $(shell jq -r .id CloudronManifest.json)
CLOUDRON_SERVER ?= my.9wd.eu
CLOUDRON_TOKEN ?=123
DOCKER_REPO ?= fbartels
.PHONY: default
@ -17,6 +19,10 @@ build:
update: build
cloudron update --app ${CLOUDRON_APP}
.PHONY: update-ci
update-ci:
cloudron update --server ${CLOUDRON_SERVER} --token ${CLOUDRON_TOKEN} --app ${CLOUDRON_APP}
.PHONY: install
install: build
cloudron install --location ${CLOUDRON_APP}

View file

@ -0,0 +1,10 @@
FROM plugins/docker:latest
RUN apk add --no-cache jq make npm perl python
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
# use --unsafe to not execute post actions as user nobody
RUN npm -g install cloudron@4.5.3 --unsafe && npm cache clean --force && \
cloudron --version

View file

@ -0,0 +1,20 @@
DOCKER_REPO ?= fbartels
DOCKER_IMAGE := cloudron-cli
VERSION := $(shell grep cloudron@ Dockerfile | cut -d' ' -f 5 | cut -d@ -f 2)
.PHONY: default
default: push
.PHONY: build
build:
docker build . -t $(DOCKER_IMAGE)
.PHONY: tag
tag: build
docker tag $(DOCKER_IMAGE) $(DOCKER_REPO)/$(DOCKER_IMAGE):latest
docker tag $(DOCKER_IMAGE) $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION)
.PHONY: push
push: tag
docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):latest
docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION)