Skip to content

Commit

Permalink
chore: add Makefile & .env file to simplify deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mcharron committed Jun 15, 2018
1 parent 840f745 commit b014943
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 26 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
spaces_around_brackets = outside
spaces_around_operators = true

[*.md]
trim_trailing_whitespace = false

[*.{php, js}]
quote_type = single

[Makefile]
indent_style = tab

[*.mk]
indent_style = tab
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MEDIAWIKIVERSION=1.31

AUTOINSTALL=oui
SERVERURL=http://localhost
WIKINAME=NaoWiki
DBNAME=mediawiki
DBPASS=HC51qp6xYIK
ADMINUSER=Admin
ADMINPASSWORD=EDI917VJb30

WEB_PORT=80
WEB_SSL_PORT=443
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
distribution-files/mediawiki/
distribution-files/*
.env
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Spread cli arguments
ifneq (,$(filter $(firstword $(MAKECMDGOALS)),exec))
CLI_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(CLI_ARGS):;@:)
endif

docker-compose = docker-compose -f docker-compose.yml $1

-include .env

init:
cp .env.example .env

config:
sed -i 's/MYSQL_ROOT_PASSWORD=.*/MYSQL_ROOT_PASSWORD=${DBPASS}/g' ./docker-compose.yml
sed -i 's/MYSQL_ROOT_PASSWORD=.*/MYSQL_ROOT_PASSWORD=${DBPASS}/g' ./autoinstall.yml
sed -i 's/MYSQL_PASSWORD=.*/MYSQL_PASSWORD=${DBPASS}/g' ./docker-compose.yml
sed -i 's/MYSQL_PASSWORD=.*/MYSQL_PASSWORD=${DBPASS}/g' ./autoinstall.yml
sudo ./runfirst.bash

up:
$(call docker-compose, up -d --force-recreate)

down:
$(call docker-compose, down --volumes)

reup: down up

destroy:
@if [ -d ./distribution-files/mediawiki ]; then sudo rm -fr ./distribution-files/mediawiki; fi
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Project Compendium: http://binaryoasis.com:8000 (Not quite reflective of the reb
## TLDR:
Runs on linux (only) kernel 3.10+ - Only tested on ubuntu 16.04

Set vars in `runfirst.bash` if you want auto install
Set vars in `.env` if you want auto install (after `make init`)
```
sudo ./runfirst.bash
sudo docker-compose up -d --force-recreate
make init
make config
make up
```

## Freshly re-engineered!
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ services:
nginx:
image: nginx:1.10
ports:
- "80:80"
- "443:443"
- "${WEB_PORT}:80"
- "${WEB_SSL_PORT}:443"
volumes:
- "./distribution-files/nginx:/etc/nginx"
- "./distribution-files/mediawiki:/var/www/mediawiki"
Expand Down
22 changes: 2 additions & 20 deletions runfirst.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,7 @@ if [[ $EUID -ne 0 ]]; then
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

MEDIAWIKIVERSION="1.30"

#Auto Install Variables
AUTOINSTALL="false" #Does not auto install by default. Set to anything other than false
SERVERURL="https://localhost" #No Trailing slash
WIKINAME="My Wiki"
DBNAME="mediawiki"
#NOTE: Due to interpolation, may have issues with special charecters on passwords.
#NOTE: This Will override the password set in the docker-compose file
DBPASS="HC51qp6xYIK"
ADMINUSER="Admin"
ADMINPASSWORD="EDI917VJb30" #Due to interpolation, may have issues with special charecters

#### Begin all the things you don't need to worry about ####

sed -i "s/MYSQL_ROOT_PASSWORD=.*/MYSQL_ROOT_PASSWORD=$DBPASS/g" $DIR/docker-compose.yml
sed -i "s/MYSQL_ROOT_PASSWORD=.*/MYSQL_ROOT_PASSWORD=$DBPASS/g" $DIR/autoinstall.yml
sed -i "s/MYSQL_PASSWORD=.*/MYSQL_PASSWORD=$DBPASS/g" $DIR/docker-compose.yml
sed -i "s/MYSQL_PASSWORD=.*/MYSQL_PASSWORD=$DBPASS/g" $DIR/autoinstall.yml
source .env

#system prep
command -v docker >/dev/null 2>&1 || { curl -s https://get.docker.com/ | bash; }
Expand Down Expand Up @@ -148,5 +130,5 @@ if [[ $AUTOINSTALL != "false" ]]; then
docker rm -f no-one-else-should-be-using-this-name-or-this

clear
printf "\nYour wiki has been created, now you can run:\ndocker-compose up [-d] [--force-recreate] \n\n"
printf "\nYour wiki has been created, now you can run:\nmake up \n\n"
fi

0 comments on commit b014943

Please sign in to comment.