From 3284204281c89ba5d935b8b4400ed4a1fbc00670 Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Sun, 18 May 2025 16:37:48 +0200 Subject: [PATCH] chore: initial commit with Docker + Ansible base --- .gitignore | 7 +++++++ Makefile | 16 ++++++++++++++++ ansible/deploy.yml | 4 ++++ ansible/inventory.ini | 2 ++ ansible/roles/deploy/tasks/main.yml | 14 ++++++++++++++ ansible/roles/setup/tasks/main.yml | 3 +++ ansible/setup.yml | 4 ++++ app/Dockerfile | 3 +++ app/html/index.php | 2 ++ app/nginx/default.conf | 17 +++++++++++++++++ docker-compose.yml | 16 ++++++++++++++++ 11 files changed, 88 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 ansible/deploy.yml create mode 100644 ansible/inventory.ini create mode 100644 ansible/roles/deploy/tasks/main.yml create mode 100644 ansible/roles/setup/tasks/main.yml create mode 100644 ansible/setup.yml create mode 100644 app/Dockerfile create mode 100644 app/html/index.php create mode 100644 app/nginx/default.conf create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4565ba90 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.idea/ +vendor/ +node_modules/ +.env +*.log +*.retry +ansible/.vault_pass diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..427811a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: deploy setup stop build restart + +setup: + ansible-playbook -i ansible/inventory.ini ansible/setup.yml + +deploy: + ansible-playbook -i ansible/inventory.ini ansible/deploy.yml + +stop: + docker compose down + +build: + docker compose build --no-cache + +restart: stop build + docker compose up -d diff --git a/ansible/deploy.yml b/ansible/deploy.yml new file mode 100644 index 00000000..fd525065 --- /dev/null +++ b/ansible/deploy.yml @@ -0,0 +1,4 @@ +- hosts: web + become: false + roles: + - deploy diff --git a/ansible/inventory.ini b/ansible/inventory.ini new file mode 100644 index 00000000..09cdead9 --- /dev/null +++ b/ansible/inventory.ini @@ -0,0 +1,2 @@ +[web] +localhost ansible_connection=local \ No newline at end of file diff --git a/ansible/roles/deploy/tasks/main.yml b/ansible/roles/deploy/tasks/main.yml new file mode 100644 index 00000000..9d24ba21 --- /dev/null +++ b/ansible/roles/deploy/tasks/main.yml @@ -0,0 +1,14 @@ +- name: Stoppe laufende Container + command: docker compose down + args: + chdir: "{{ playbook_dir }}/../" + +- name: Baue Images neu (ohne Cache) + command: docker compose build --no-cache + args: + chdir: "{{ playbook_dir }}/../" + +- name: Starte Container neu + command: docker compose up -d + args: + chdir: "{{ playbook_dir }}/../" diff --git a/ansible/roles/setup/tasks/main.yml b/ansible/roles/setup/tasks/main.yml new file mode 100644 index 00000000..af820109 --- /dev/null +++ b/ansible/roles/setup/tasks/main.yml @@ -0,0 +1,3 @@ +- name: Test-Task Setup-Rolle lokal + debug: + msg: "Setup-Rolle ist vorbereitet – echte Installation folgt auf Server." diff --git a/ansible/setup.yml b/ansible/setup.yml new file mode 100644 index 00000000..3786e69a --- /dev/null +++ b/ansible/setup.yml @@ -0,0 +1,4 @@ +- hosts: web + become: false + roles: + - setup diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 00000000..2f977791 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:stable-alpine + +COPY nginx/default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/app/html/index.php b/app/html/index.php new file mode 100644 index 00000000..84f4b4b5 --- /dev/null +++ b/app/html/index.php @@ -0,0 +1,2 @@ +