diff --git a/roles/docker-simpleicons/README.md b/roles/docker-simpleicons/README.md new file mode 100644 index 00000000..22f6a2eb --- /dev/null +++ b/roles/docker-simpleicons/README.md @@ -0,0 +1,34 @@ +# Simple Icons + +## Description + +This Ansible role deploys and manages a containerized [Simple Icons](https://simpleicons.org/) server, providing easy access to over 2,000 SVG and PNG icons for use in web projects, documentation, and branding. + +## Overview + +Ideal for developers and content creators, the role simplifies deploying a dedicated icon server. It automates container setup, configuration, and routing, ensuring reliable, quick access to icons. Easily integrate scalable icons into your projects without managing individual asset files. + +## Purpose + +The Docker-SimpleIcons role streamlines the deployment and management of a simple, efficient icon server. It helps you: +- Quickly deploy a lightweight, dedicated icon server. +- Serve icons consistently and reliably across multiple projects. +- Reduce manual maintenance of icon assets. +- Integrate seamlessly with complementary Ansible roles and web server configurations. + +## Features + +- **Icon Server:** Serves scalable SVG and PNG icons from the Simple Icons collection. +- **Containerized Deployment:** Utilizes Docker and Docker Compose for isolated, reliable deployment. +- **Dynamic Icon Delivery:** Icons are dynamically served via RESTful endpoints. +- **Customizable Setup:** Configure icon sizes, formats, and routes effortlessly. +- **Efficient Integration:** Works seamlessly with web server roles for robust domain routing. +- **Automated Maintenance:** Simplifies updates and re-deployments via automated container management. + +## Credits 📝 + +Developed and maintained by **Kevin Veen-Birkenbach**. +Learn more at [www.veen.world](https://www.veen.world) + +Part of the [CyMaIS Project](https://github.com/kevinveenbirkenbach/cymais) +License: [CyMaIS NonCommercial License (CNCL)](https://s.veen.world/cncl) \ No newline at end of file diff --git a/roles/docker-simpleicons/files/env b/roles/docker-simpleicons/files/env deleted file mode 100644 index e69de29b..00000000 diff --git a/roles/docker-simpleicons/meta/main.yml b/roles/docker-simpleicons/meta/main.yml new file mode 100644 index 00000000..a80d07d4 --- /dev/null +++ b/roles/docker-simpleicons/meta/main.yml @@ -0,0 +1,26 @@ +galaxy_info: + author: "Kevin Veen-Birkenbach" + description: "Deploy and serve SVG and PNG icons effortlessly with Simple Icons, a containerized icon server ideal for web projects, documentation, and branding." + license: "CyMaIS NonCommercial License (CNCL)" + license_url: "https://s.veen.world/cncl" + company: | + Kevin Veen-Birkenbach + Consulting & Coaching Solutions + https://www.veen.world + min_ansible_version: "2.9" + platforms: + - name: Docker + versions: + - latest + galaxy_tags: + - docker + - icons + - branding + - svg + - png + repository: "https://s.veen.world/cymais" + issue_tracker_url: "https://s.veen.world/cymaisissues" + documentation: "https://s.veen.world/cymais" + logo: + class: "fa-solid fa-icons" + run_after: [] diff --git a/roles/docker-simpleicons/tasks/main.yml b/roles/docker-simpleicons/tasks/main.yml new file mode 100644 index 00000000..a65e7216 --- /dev/null +++ b/roles/docker-simpleicons/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: "include docker-compose role" + include_role: + name: docker-compose + when: run_once_docker_simpleicons is not defined + +- name: "include role nginx-domain-setup for {{application_id}}" + include_role: + name: nginx-domain-setup + vars: + domain: "{{ domains | get_domain(application_id) }}" + http_port: "{{ ports.localhost.http[application_id] }}" + when: run_once_docker_simpleicons is not defined + +- name: "Copy '{{ application_id }}' files" + template: + src: "{{ item.source }}" + dest: "{{ item.target }}" + mode: '0755' + loop: + - { source: "server.js.j2", target: "{{ simpleicons_host_server_file }}" } + - { source: "package.json.j2", target: "{{ simpleicons_host_package_file }}" } + notify: + - docker compose up + when: run_once_docker_simpleicons is not defined + +- name: run the simpleicons tasks once + set_fact: + run_once_docker_portfolio: true + when: run_once_docker_simpleicons is not defined diff --git a/roles/docker-simpleicons/files/Dockerfile b/roles/docker-simpleicons/templates/Dockerfile.j2 similarity index 66% rename from roles/docker-simpleicons/files/Dockerfile rename to roles/docker-simpleicons/templates/Dockerfile.j2 index b10d1dd9..2dda8d25 100644 --- a/roles/docker-simpleicons/files/Dockerfile +++ b/roles/docker-simpleicons/templates/Dockerfile.j2 @@ -1,7 +1,7 @@ FROM node:latest AS builder WORKDIR /app -COPY package*.json ./ +COPY ./config/package*.json ./ RUN npm install @@ -9,8 +9,8 @@ FROM node:latest WORKDIR /app COPY --from=builder /app/node_modules ./node_modules -COPY server.js . +COPY ./config/server.js . -EXPOSE 3000 +EXPOSE {{ container_port }} CMD ["node", "server.js"] diff --git a/roles/docker-simpleicons/templates/docker-compose.yml.j2 b/roles/docker-simpleicons/templates/docker-compose.yml.j2 index 83575766..23e9d130 100644 --- a/roles/docker-simpleicons/templates/docker-compose.yml.j2 +++ b/roles/docker-simpleicons/templates/docker-compose.yml.j2 @@ -6,9 +6,9 @@ image: simpleicons-server:latest container_name: simpleicons-server ports: - - "{{ports.localhost.http[application_id]}}:3000" + - "{{ports.localhost.http[application_id]}}:{{ container_port }}" {% include 'roles/docker-container/templates/base.yml.j2' %} {% include 'roles/docker-container/templates/networks.yml.j2' %} +{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %} {% include 'roles/docker-compose/templates/networks.yml.j2' %} - diff --git a/roles/docker-simpleicons/templates/env.j2 b/roles/docker-simpleicons/templates/env.j2 new file mode 100644 index 00000000..641e9d04 --- /dev/null +++ b/roles/docker-simpleicons/templates/env.j2 @@ -0,0 +1 @@ +{# This file just exists, because the framework requests it. #} \ No newline at end of file diff --git a/roles/docker-simpleicons/files/package.json b/roles/docker-simpleicons/templates/package.json.j2 similarity index 100% rename from roles/docker-simpleicons/files/package.json rename to roles/docker-simpleicons/templates/package.json.j2 diff --git a/roles/docker-simpleicons/templates/server.js.j2 b/roles/docker-simpleicons/templates/server.js.j2 index b5a61a13..7034fe30 100644 --- a/roles/docker-simpleicons/templates/server.js.j2 +++ b/roles/docker-simpleicons/templates/server.js.j2 @@ -3,7 +3,7 @@ import * as icons from 'simple-icons'; import sharp from 'sharp'; const app = express(); -const port = process.env.PORT || 3000; +const port = {{ container_port }}; // Helper: convert 'nextcloud' → 'siNextcloud' function getExportName(slug) { @@ -15,7 +15,7 @@ function getExportName(slug) { // Root: redirect to your documentation app.get('/', (req, res) => { - res.redirect('https://docs.cymais.cloud/roles/docker-{{ application_id }}/README.html'); + res.redirect('{{ domains | get_url('sphinx', web_protocol) }}/roles/docker-{{ application_id }}/README.html'); }); // GET /:slug.svg diff --git a/roles/docker-simpleicons/vars/configuration.yml b/roles/docker-simpleicons/vars/configuration.yml new file mode 100644 index 00000000..321b35d9 --- /dev/null +++ b/roles/docker-simpleicons/vars/configuration.yml @@ -0,0 +1,27 @@ + +credentials: {} +docker: + images: {} # @todo Move under services + versions: {} # @todo Move under services + services: + redis: + enabled: false # Enable Redis + database: + enabled: false # Enable the database +features: + matomo: true # Enable Matomo Tracking + css: true # Enable Global CSS Styling + portfolio_iframe: true # Enable loading of app in iframe + ldap: false # Enable LDAP Network + central_database: false # Enable Central Database Network + recaptcha: false # Enable ReCaptcha + oauth2: false # Enable the OAuth2-Proy +csp: +domains: + canonical: + - "icons.{{ primary_domain }}" +rbac: + roles: + mail-bot: + description: "Has an token to send and recieve emails" + diff --git a/roles/docker-simpleicons/vars/main.yml b/roles/docker-simpleicons/vars/main.yml index e2a49383..efec6b90 100644 --- a/roles/docker-simpleicons/vars/main.yml +++ b/roles/docker-simpleicons/vars/main.yml @@ -1 +1,4 @@ -application_id: simpleicons \ No newline at end of file +application_id: simpleicons +container_port: 3000 +simpleicons_host_server_file: "{{docker_compose.directories.config}}server.js" +simpleicons_host_package_file: "{{docker_compose.directories.config}}package.json" \ No newline at end of file