Add one click installer scripts/autoinstall.sh

This commit is contained in:
Jan Tuomi
2017-03-03 02:02:40 +02:00
parent bf9aad4f4c
commit 307ddbdca6
11 changed files with 300 additions and 2 deletions
+56
View File
@@ -0,0 +1,56 @@
#!/bin/bash
echo "Checking if docker is installed..."
docker --version
if [ "$?" -ne 0 ]
then
echo "Installing docker..."
apt install docker -y
fi
echo "Checking if docker-compose is installed..."
docker-compose --version
if [ "$?" -ne 0 ]
then
echo "Installing docker-compose 1.11.2..."
curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
fi
echo "Building db container..."
docker-compose build db
echo "Starting db container..."
docker-compose up -d db
echo "Waiting 10 seconds..."
sleep 10
echo "Importing database settings..."
docker-compose exec db sh /db/install.sh
if [ "$?" -eq 0 ]
then
echo "Success!"
else
echo "Failure!"
exit 1
fi
echo "Shutting down db container..."
echo "Copying settings..."
cp sikweb/settings-docker-sample.py sikweb/settings.py
echo "Building web container..."
docker-compose build web
echo "Running manage.py commands..."
docker-compose run web python manage.py migrate
docker-compose run web python manage.py makemigrations infoscreen members webapp
docker-compose run web python manage.py migrate
docker-compose run web python manage.py createdefaultadmin
echo "Starting all containers..."
docker-compose up -d
echo "Done."
+5
View File
@@ -0,0 +1,5 @@
FROM mariadb:latest
RUN mkdir -p /db
WORKDIR /db
ADD scripts/db/init.sql /db/
ADD scripts/db/install.sh /db/
+5
View File
@@ -0,0 +1,5 @@
CREATE USER 'sik'@'%' IDENTIFIED BY 'password123';
CREATE DATABASE sik DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON `sik\_%` . * TO 'sik'@'%' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON sik.* TO 'sik'@'%';
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
set -e
mysql -u root -ptoor < /db/init.sql
+7
View File
@@ -0,0 +1,7 @@
FROM python:3.5
ENV PYTHONBUFFERED 1
RUN mkdir -p /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
+1
View File
@@ -0,0 +1 @@
../../requirements.txt