diff --git a/Makefile b/Makefile deleted file mode 100644 index 147a594..0000000 --- a/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -IMAGE_NAME="alp-mdb" -CONTAINER_NAME="inst1" -LOG="/tmp/ptut.virtenv.log" -LOCK="/tmp/ptut.virtenv.lock" - -image: build - @echo -n "> Build image.................."; - @docker build --force-rm -t $(IMAGE_NAME) . >>$(LOG) 2>&1 && echo "done" || echo "error"; - -build: docker/main docker/include/* - @echo -n "> Build Dockerfile............."; - @cpp -o Dockerfile docker/main && echo "done" || echo "error"; - -clean: - @echo -n "> Stop container..............."; - @docker stop $(CONTAINER_NAME) >/dev/null 2>&1 && echo "stopped" || echo "already"; true; - @echo -n "> Delete container............."; - @docker rm -f $(CONTAINER_NAME) >/dev/null 2>&1 && echo "deleted" || echo "already"; true; - @echo -n "> Delete image................."; - @docker rmi -f $(IMAGE_NAME) >/dev/null 2>&1 && echo "deleted" || echo "already"; true; - @echo -n "> Delete Dockerfile............"; - @rm Dockerfile >/dev/null 2>&1 && echo "done" || echo "already"; true - @echo -n "> Delete log file.............."; - @rm $(LOG) >/dev/null 2>&1 && echo "done" || echo "already"; true - @echo -n "> Delete lock file............."; - @rm $(LOCK) >/dev/null 2>&1 && echo "done" || echo "already"; true - -run: - @echo ">>> Search running container"; - @test ! -f $(LOCK) && echo -e "<<< nothing\n" || (echo -e "<<< found\n\nERR: You must run 'make clean' before running a new container"; exit 1); - @echo ">>> Build image"; - @make image; - @echo -e "<<< built\n"; - @echo ">>> Container launched"; - @touch $(LOCK); - @docker run --name $(CONTAINER_NAME) $(IMAGE_NAME); - @echo -e "<<< stopped\n"; - @echo ">>> clean installation" | tee -a $(LOG); \ - make clean; - @echo "<<< cleaned"; - -kill: - @echo -n "Search running container......."; - @test -f $(LOCK) && echo "found" || (echo -e "nothing\n\nERR: You must run a container to kill it"; exit 1); - @echo -n "Kill container................."; - @docker exec -ti inst1 sh -c 'rm boot.lock' && echo "killed" || echo "error"; - -boot: - @touch $(LOG); - @while true; do \ - echo ">>> pull from source" | tee -a $(LOG); \ - git pull origin master >> $(LOG) 2>&1 && echo -e "<<< pulled\n" || echo -e "<<< error\n"; \ - echo ">>> make image" | tee -a $(LOG); \ - make image; \ - echo -e ">>> made\n" | tee -a $(LOG); \ - echo ">>> launch container" | tee -a $(LOG); \ - touch $(LOCK); \ - docker run --name $(CONTAINER_NAME) $(IMAGE_NAME) >> $(LOG) 2>&1; \ - echo -e "<<< stopped\n" | tee -a $(LOG); \ - echo ">>> clean installation" | tee -a $(LOG); \ - make clean; \ - echo -e "<<< cleaned\n"; \ - sleep 2; \ - done; - -log: - @echo -n "> Checking log file......."; - @test -f $(LOG) && echo "found" || (echo "missing"; exit 1); - @echo -n "> Checking container......"; - @test -f $(LOCK) && echo "running" || echo "not running"; - @echo "====== LOG ======"; - @tail -f $(LOG); - -tty: - @echo -n "> Checking lock..........."; - @test -f $(LOCK) && echo "found" || (echo "missing"; exit 1); - @echo "> Connecting tty............."; - @docker exec -ti $(CONTAINER_NAME) sh; diff --git a/README.md b/README.md index 3f840ac..bbcb2f6 100644 --- a/README.md +++ b/README.md @@ -5,66 +5,25 @@ You need a consistent Linux System with the following packages : - `docker` -- `make` -- `cpp` (C pre-processor) +- `docker-compose` +You need to add a local dns record in `/etc/hosts`: +```text +127.0.0.1 ptut.com +``` + ## Commands -In order for the environment to be launched, we need to run configuration commands, installation instructions, etc and store the final state in a **docker image**. Then we can launch several **containers** from that initial image. - -The building process is automated with the *Makefile* and the `make` command. - ---- -### 1. Build the Dockerfile +**Launch the environment** ```bash -make build +docker-compose up -d ``` +- the mounted files will match in the `./virtual` folder. +- the website will be accessible at 'ptut.com:8080'. -- Creates the *Dockerfile* using the *c pre-processor* to include the files in `docker/include` in `docker/main`. The final output is located at the root of the repository in `./Dockerfile`. - ---- -### 2. Create the docker image - +**Stop the environment** ```bash -make image -``` - -- Creates the **docker image** from the Dockerfile. If `./Dockerfile` is missing, it will automatically launch `make build`. - ---- -### 3. Launch the container - -```bash -make run -``` - -- Builds the image (*make image*) -- Launches the container (*make run*) - ---- -### 4. Properly kill a container - -```bash -make kill -``` - -- Properly kills a running container - - ---- -### 5. Launch the CI loop - -```bash -make boot -``` - -- Launches an infinite loop that - 1. Updates the git repository (*git pull*) - 2. Builds the image (*make image*) - 3. Launches the container (*make run*) - 4. When the container stops, delete it and reloop - -- to have a real time log, launch `make log` -- to connect to a tty launch `make tty` \ No newline at end of file +docker-compose down +``` \ No newline at end of file diff --git a/docker/include/mariadb b/docker/include/mariadb deleted file mode 100644 index 72c7433..0000000 --- a/docker/include/mariadb +++ /dev/null @@ -1,4 +0,0 @@ -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 */ \ No newline at end of file diff --git a/docker/main b/docker/main deleted file mode 100644 index 4df4f76..0000000 --- a/docker/main +++ /dev/null @@ -1,19 +0,0 @@ -/* 1. Base image */ -FROM alpine -MAINTAINER xdrm-brackets - -/* 2. Update package manager */ -RUN apk update - - -/************************************ -************** MariaDB ************** -************************************/ -#include "./include/mariadb" - - -/************************************ -********** Set Bootloader *********** -************************************/ -COPY virtual/bootloader /bootloader -CMD export USER=ROOT; sh /bootloader