From ddb71f504befeea92663cc99ef1f26be097792cc Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Dec 2022 20:20:02 +0100 Subject: [PATCH] Implemented draft four roulette wheel --- playbook.yml | 8 ++++ roles/docker-roulette-wheel/handlers/main.yml | 8 ++++ roles/docker-roulette-wheel/meta/main.yml | 2 + roles/docker-roulette-wheel/readme.md | 7 ++++ roles/docker-roulette-wheel/tasks/main.yml | 41 +++++++++++++++++++ .../templates/Dockerfile.j2 | 8 ++++ .../templates/docker-compose.yml.j2 | 9 ++++ roles/docker-roulette-wheel/vars/main.yml | 2 + 8 files changed, 85 insertions(+) create mode 100644 roles/docker-roulette-wheel/handlers/main.yml create mode 100644 roles/docker-roulette-wheel/meta/main.yml create mode 100644 roles/docker-roulette-wheel/readme.md create mode 100644 roles/docker-roulette-wheel/tasks/main.yml create mode 100644 roles/docker-roulette-wheel/templates/Dockerfile.j2 create mode 100644 roles/docker-roulette-wheel/templates/docker-compose.yml.j2 create mode 100644 roles/docker-roulette-wheel/vars/main.yml diff --git a/playbook.yml b/playbook.yml index f194d7fa..2d03f440 100644 --- a/playbook.yml +++ b/playbook.yml @@ -151,6 +151,14 @@ vars: domain: funkwhale.{{top_domain}} http_port: 8012 +- name: setup roulette-wheel hosts + hosts: roulette_wheel_hosts + become: true + roles: + - role: docker-roulette-wheel + vars: + domain: roulette.{{top_domain}} + http_port: 8013 - name: setup akaunting hosts hosts: akaunting_hosts become: true diff --git a/roles/docker-roulette-wheel/handlers/main.yml b/roles/docker-roulette-wheel/handlers/main.yml new file mode 100644 index 00000000..afd97aed --- /dev/null +++ b/roles/docker-roulette-wheel/handlers/main.yml @@ -0,0 +1,8 @@ +--- +- name: setup roulette-wheel + command: + cmd: docker-compose -p roulette-wheel up -d --force-recreate + chdir: "{{docker_compose_path}}" + environment: + COMPOSE_HTTP_TIMEOUT: 600 + DOCKER_CLIENT_TIMEOUT: 600 diff --git a/roles/docker-roulette-wheel/meta/main.yml b/roles/docker-roulette-wheel/meta/main.yml new file mode 100644 index 00000000..fb4d4f7b --- /dev/null +++ b/roles/docker-roulette-wheel/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- native-docker-reverse-proxy diff --git a/roles/docker-roulette-wheel/readme.md b/roles/docker-roulette-wheel/readme.md new file mode 100644 index 00000000..689dff46 --- /dev/null +++ b/roles/docker-roulette-wheel/readme.md @@ -0,0 +1,7 @@ +# docker roulette-wheel + +## further information +- https://github.com/p-wojt/roulette-wheel +- https://dev.to/ms314006/how-to-package-front-end-projects-into-docker-images-and-use-it-with-webpack-go3 +- https://stackoverflow.com/questions/53178820/dockerfile-to-run-nodejs-static-content-in-docker-container +- https://stackoverflow.com/questions/43619644/i-am-getting-an-invalid-host-header-message-when-connecting-to-webpack-dev-ser \ No newline at end of file diff --git a/roles/docker-roulette-wheel/tasks/main.yml b/roles/docker-roulette-wheel/tasks/main.yml new file mode 100644 index 00000000..9a90212d --- /dev/null +++ b/roles/docker-roulette-wheel/tasks/main.yml @@ -0,0 +1,41 @@ +--- +- name: recieve {{domain}} certificate + command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{domain}} + +- name: configure {{domain}}.conf + template: src=roles/native-docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{domain}}.conf + notify: restart nginx + +- name: "create {{docker_compose_path}}" + file: + path: "{{docker_compose_path}}" + state: directory + mode: 0755 + +#- name: register directory +# stat: +# path: "{{docker_compose_path}}" +# register: docker_compose_path_register +# +#- name: checkout repository +# ansible.builtin.shell: git checkout . +# become: true +# args: +# chdir: "{{docker_compose_path}}" +# when: docker_compose_path_register.stat.exists + +- name: pull app repository + git: + repo: "https://github.com/p-wojt/roulette-wheel.git" + dest: "{{app_path}}" + update: yes + notify: setup roulette-wheel + become: true + +- name: add docker-compose.yml + template: src=docker-compose.yml.j2 dest={{docker_compose_path}}docker-compose.yml + notify: setup roulette-wheel + +- name: add Dockerfile + template: src=Dockerfile.j2 dest={{docker_compose_path}}Dockerfile + notify: setup roulette-wheel diff --git a/roles/docker-roulette-wheel/templates/Dockerfile.j2 b/roles/docker-roulette-wheel/templates/Dockerfile.j2 new file mode 100644 index 00000000..2ffeebcf --- /dev/null +++ b/roles/docker-roulette-wheel/templates/Dockerfile.j2 @@ -0,0 +1,8 @@ +FROM node:latest +WORKDIR /app +COPY {{app_path}}package.json ./ +RUN npm install +COPY {{app_path}} ./ +RUN npm run build +EXPOSE 8080 +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/roles/docker-roulette-wheel/templates/docker-compose.yml.j2 b/roles/docker-roulette-wheel/templates/docker-compose.yml.j2 new file mode 100644 index 00000000..d55d4231 --- /dev/null +++ b/roles/docker-roulette-wheel/templates/docker-compose.yml.j2 @@ -0,0 +1,9 @@ +version: '3.7' +services: + application: + container_name: application + build: + context: . + ports: + - 127.0.0.1:{{http_port}}:8080 + restart: unless-stopped \ No newline at end of file diff --git a/roles/docker-roulette-wheel/vars/main.yml b/roles/docker-roulette-wheel/vars/main.yml new file mode 100644 index 00000000..d25db187 --- /dev/null +++ b/roles/docker-roulette-wheel/vars/main.yml @@ -0,0 +1,2 @@ +docker_compose_path: "/home/administrator/docker-compose/roulette-wheel/" +app_path: "/home/administrator/docker-compose/roulette-wheel/app" \ No newline at end of file