Skip to content

Commit

Permalink
Add Drone CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosbunker committed May 4, 2019
1 parent 926ff71 commit 93c3bbc
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
12 changes: 12 additions & 0 deletions data/services/droneci/containers.sh
@@ -0,0 +1,12 @@
droneci_service_dockerbunker() {
docker run -d \
--name=${FUNCNAME[0]//_/-} \
--restart=always \
--network ${NETWORK} \
--env-file "${SERVICE_ENV}" \
--publish=7777:80 \
--detach=true \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${SERVICE_NAME}-data-vol-1:${volumes[${SERVICE_NAME}-data-vol-1]} \
${IMAGES[service]} ${ID} >/dev/null
}
59 changes: 59 additions & 0 deletions data/services/droneci/droneci.sh
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

while true;do ls | grep -q dockerbunker.sh;if [[ $? == 0 ]];then BASE_DIR=$PWD;break;else cd ../;fi;done

PROPER_NAME="Drone CI"
SERVICE_NAME="$(echo -e "${PROPER_NAME,,}" | tr -cd '[:alnum:]')"
PROMPT_SSL=1

declare -a environment=( "data/env/dockerbunker.env" "data/include/init.sh" )

for env in "${environment[@]}";do
[[ -f "${BASE_DIR}"/$env ]] && source "${BASE_DIR}"/$env
done

declare -A WEB_SERVICES
declare -a containers=( "${SERVICE_NAME}-service-dockerbunker" )
declare -a add_to_network=( "${SERVICE_NAME}-service-dockerbunker" )
declare -A IMAGES=( [service]="drone/drone:1" )
declare -A volumes=( [${SERVICE_NAME}-data-vol-1]="/data" )
declare -a networks=( )

[[ -z $1 ]] && options_menu

configure() {
pre_configure_routine

echo -e "# \e[4mDrone CI Settings\e[0m"

set_domain

read -p "Gogs server address: " -ei "https://" DRONE_GOGS_SERVER

read -p "Gogs username: " -ei "" GOGS_USER

cat <<-EOF >> "${SERVICE_ENV}"
PROPER_NAME="${PROPER_NAME}"
SERVICE_NAME=${SERVICE_NAME}
SSL_CHOICE=${SSL_CHOICE}
LE_EMAIL=${LE_EMAIL}
DRONE_GOGS_SERVER=${DRONE_GOGS_SERVER}
DRONE_SERVER_HOST=${SERVICE_DOMAIN}
DRONE_SERVER_PROTO=https
DRONE_RUNNER_CAPACITY=2
DRONE_TLS_AUTOCERT=false
DRONE_GIT_ALWAYS_AUTH=false
DRONE_USER_CREATE=username:${GOGS_USER},admin:true
DRONE_DATABASE_SECRET=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32)
SERVICE_DOMAIN=${SERVICE_DOMAIN}
EOF

post_configure_routine
}

if [[ $1 == "letsencrypt" ]];then
$1 $*
else
$1
fi
49 changes: 49 additions & 0 deletions data/services/droneci/nginx/droneci.conf
@@ -0,0 +1,49 @@
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
upstream droneci {
server droneci-service-dockerbunker:80;
}

server {
listen 80;
server_name ${SERVICE_DOMAIN};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name ${SERVICE_DOMAIN};
ssl_certificate /etc/nginx/ssl/${SERVICE_DOMAIN}/cert.pem;
ssl_certificate_key /etc/nginx/ssl/${SERVICE_DOMAIN}/key.pem;
include /etc/nginx/includes/ssl.conf;

add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;

include /etc/nginx/includes/gzip.conf;

location / {
proxy_pass http://droneci/;
}

location ~ /.well-known {
allow all;
root /var/www/html;
}
}


1 change: 1 addition & 0 deletions dockerbunker.sh
Expand Up @@ -27,6 +27,7 @@ declare -a ALL_SERVICES=( \
"Cryptpad" \
"CS50 IDE" \
"Dillinger" \
"Drone CI" \
"Ghost" \
"GitBucket" \
"Gitea" \
Expand Down

0 comments on commit 93c3bbc

Please sign in to comment.