First commit

This commit is contained in:
xdrm-brackets 2018-02-16 01:49:02 +01:00
commit 6a5e70ccf2
5 changed files with 75 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/Dockerfile
/mount/*

35
Makefile Normal file
View File

@ -0,0 +1,35 @@
IMAGE_NAME="alp-mdb"
build: clean Dockerfile
@echo -n "> Building image...............";
docker build --force-rm -t $(IMAGE_NAME) . && echo "done" || echo "error";
Dockerfile: docker/main docker/include/*
@echo -n "> Building file Dockerfile.....";
@cpp -o Dockerfile docker/main && echo "done" || echo "error";
clean:
@echo -n "> Stopping containers..........";
@docker stop inst1;
@docker rm -flv inst1;
@echo -n "> Deleting docker image........";
@docker rmi -f $(IMAGE_NAME) && echo "done" || echo "failed";
@echo -n "> Deleting Dockerfile..........";
@rm Dockerfile && echo "done" || echo "failed";
boot:
@while true; do \
echo "*** 1. Updating virtual environment"; \
git pull origin stable; \
echo "*** 2. Building image"; \
make build; \
echo "*** 3. Launching container"; \
docker run --name inst1 $(IMAGE_NAME); \
echo "*** 4. Deleting container"; \
docker stop inst1; \
docker rm -flv inst1; \
sleep 2; \
done;
kill:
@docker exec -ti inst1 sh -c 'rm boot.lock';

4
docker/include/mariadb Normal file
View File

@ -0,0 +1,4 @@
RUN apk add mariadb mariadb-client \ /* 1. install mariadb */
&& mysql_install_db --user=mysql \ /* 2. install database */
&& sh -c 'mysqld_safe& sleep 1' \ /* 3. Start mysql for password changing */
&& mysqladmin -u root password 'root' /* 4. set arbitrary root password */

19
docker/main Normal file
View File

@ -0,0 +1,19 @@
/* 1. Base image */
FROM alpine
MAINTAINER xdrm-brackets <xdrm.brackets.dev@gmail.com>
/* 2. Update package manager */
RUN apk update
/************************************
************** MariaDB **************
************************************/
#include "./include/mariadb"
/************************************
********** Set Bootloader ***********
************************************/
COPY virtual/bootloader /bootloader
CMD export USER=ROOT; sh /bootloader

15
virtual/bootloader Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# 1. Start mysql
nohup mysqld_safe > /var/log/mysql_log &
# 10. Create lock file
touch /boot.lock;
chmod 777 /boot.lock;
# 11. Run while lock exists
while [ -f /boot.lock ]; do sleep 1; done;