From ec2ff8d8a64fdcbc80a8f769829e103a1fd4a2d7 Mon Sep 17 00:00:00 2001 From: yena Date: Thu, 13 Feb 2025 17:13:16 +0100 Subject: [PATCH] Say goodbye to Vagrant --- .gitmodules | 21 ----- Makefile | 1 - Vagrantfile | 37 -------- ansible/playbook.yml | 79 ----------------- ansible/roles/andyceo.phpcsfixer | 1 - ansible/roles/geerlingguy.composer | 1 - ansible/roles/geerlingguy.nodejs | 1 - ansible/roles/geerlingguy.php | 1 - ansible/roles/mariadb | 1 - ansible/roles/nginx/handlers/main.yml | 5 -- ansible/roles/nginx/tasks/main.yml | 11 --- ansible/roles/nginx/templates/default.j2 | 25 ------ ansible/roles/oefenweb.yarn | 1 - ansible/roles/systemli.dovecot | 1 - docs/development/index.md | 104 +++++++++-------------- docs/development/tests.md | 42 ++++----- docs/getting-started/index.md | 38 --------- docs/installation/webserver.md | 2 +- mkdocs.yml | 7 +- 19 files changed, 68 insertions(+), 311 deletions(-) delete mode 100755 Vagrantfile delete mode 100644 ansible/playbook.yml delete mode 160000 ansible/roles/andyceo.phpcsfixer delete mode 160000 ansible/roles/geerlingguy.composer delete mode 160000 ansible/roles/geerlingguy.nodejs delete mode 160000 ansible/roles/geerlingguy.php delete mode 160000 ansible/roles/mariadb delete mode 100755 ansible/roles/nginx/handlers/main.yml delete mode 100755 ansible/roles/nginx/tasks/main.yml delete mode 100755 ansible/roles/nginx/templates/default.j2 delete mode 160000 ansible/roles/oefenweb.yarn delete mode 160000 ansible/roles/systemli.dovecot delete mode 100644 docs/getting-started/index.md diff --git a/.gitmodules b/.gitmodules index bb9d2461..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,21 +0,0 @@ -[submodule "ansible/roles/geerlingguy.composer"] - path = ansible/roles/geerlingguy.composer - url = https://github.com/geerlingguy/ansible-role-composer.git -[submodule "ansible/roles/geerlingguy.nodejs"] - path = ansible/roles/geerlingguy.nodejs - url = https://github.com/geerlingguy/ansible-role-nodejs.git -[submodule "ansible/roles/oefenweb.yarn"] - path = ansible/roles/oefenweb.yarn - url = https://github.com/Oefenweb/ansible-yarn.git -[submodule "ansible/roles/andyceo.phpcsfixer"] - path = ansible/roles/andyceo.phpcsfixer - url = https://github.com/andyceo/ansible-role-php-cs-fixer.git -[submodule "ansible/roles/systemli.dovecot"] - path = ansible/roles/systemli.dovecot - url = https://github.com/systemli/ansible-role-dovecot.git -[submodule "ansible/roles/geerlingguy.php"] - path = ansible/roles/geerlingguy.php - url = https://github.com/geerlingguy/ansible-role-php.git -[submodule "ansible/roles/mariadb"] - path = ansible/roles/mariadb - url = https://github.com/systemli/ansible-role-mariadb.git diff --git a/Makefile b/Makefile index 0a8c6d67..0f1fbdda 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,6 @@ reset: clean rm -rf public/build rm -rf public/bundles rm -rf public/components - rm -rf .vagrant/ rm -f ansible/playbook.retry rm -rf var/log/* rm -rf var/cache/* diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100755 index d0012cf7..00000000 --- a/Vagrantfile +++ /dev/null @@ -1,37 +0,0 @@ -$script = <<-SCRIPT -# Change directory automatically on ssh login -if ! grep -qF "cd /vagrant" /home/vagrant/.bashrc ; -then echo "cd /vagrant" >> /home/vagrant/.bashrc ; fi -chown vagrant: /home/vagrant/.bashrc -SCRIPT - -Vagrant.configure("2") do |config| - - config.vm.provider :libvirt do |v| - v.cpus = "2" - v.memory = "2048" - end - - config.vm.provider :virtualbox do |v| - v.name = "userli" - v.cpus = "2" - v.memory = "2048" - end - - config.vm.box = "debian/bookworm64" - config.vm.hostname = "userli" - config.vm.network :private_network, ip: "192.168.60.99" - config.vm.synced_folder "./", "/vagrant", - type: "nfs", - nfs_udp: false, - linux__nfs_options: ['rw','no_subtree_check','all_squash','async'] - config.ssh.forward_agent = true - - config.vm.provision "ansible" do |ansible| - ansible.galaxy_role_file = "requirements.yml" - ansible.playbook = "ansible/playbook.yml" - ansible.compatibility_mode = "2.0" - end - - config.vm.provision "shell", inline: $script -end diff --git a/ansible/playbook.yml b/ansible/playbook.yml deleted file mode 100644 index 0b14bec3..00000000 --- a/ansible/playbook.yml +++ /dev/null @@ -1,79 +0,0 @@ -- hosts: all - become: yes - pre_tasks: - - name: Install dependencies - apt: - name: "{{ apt_packages }}" - update_cache: true - roles: - - nginx - - mariadb - - systemli.dovecot - - geerlingguy.php - - geerlingguy.composer - - geerlingguy.nodejs - - oefenweb.yarn - #- andyceo.phpcsfixer - vars: - __testing: true # don't create DH param - dovecot_disable_plaintext_auth: "no" - dovecot_postfix_auth: true - apt_packages: - - git - - gnupg - - make - - postfix - - unzip - - zip - mariadb_databases: - - mail - - mail_test - mariadb_users: - - name: mail - host: localhost - password: password - priv: "mail.*:ALL" - - name: mail_test - host: localhost - password: password - priv: "mail_test.*:ALL" - nodejs_version: "18.x" - php_default_version_debian: 8.2 - php_packages: - # necessary - - php{{ php_default_version_debian }}-apcu - - php{{ php_default_version_debian }}-cli - - php{{ php_default_version_debian }}-curl - - php{{ php_default_version_debian }}-fpm - - php{{ php_default_version_debian }}-gd - - php{{ php_default_version_debian }}-mbstring - - php{{ php_default_version_debian }}-mysql - - php{{ php_default_version_debian }}-sqlite3 - - php{{ php_default_version_debian }}-xml - - php{{ php_default_version_debian }}-zip - # performance - - php{{ php_default_version_debian }}-ctype - - php{{ php_default_version_debian }}-intl - # debugging - - php{{ php_default_version_debian }}-xdebug - php_webserver_daemon: nginx - tasks: - - name: composer install - composer: - command: install - working_dir: /vagrant - no_dev: False - become: true - become_user: vagrant - - name: create WKD base directory - file: - path: "/var/www/html/.well-known/openpgpkey" - state: directory - owner: www-data - group: www-data - mode: 0755 - # XXX: Don't know why this is necessary, but it is - - name: restart php{{ php_default_version_debian }}-fpm - service: - name: php{{ php_default_version_debian }}-fpm - state: restarted diff --git a/ansible/roles/andyceo.phpcsfixer b/ansible/roles/andyceo.phpcsfixer deleted file mode 160000 index e72cc486..00000000 --- a/ansible/roles/andyceo.phpcsfixer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e72cc486acfdbb8ec39addc99df0e347f208ec9a diff --git a/ansible/roles/geerlingguy.composer b/ansible/roles/geerlingguy.composer deleted file mode 160000 index 4022d567..00000000 --- a/ansible/roles/geerlingguy.composer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4022d567a97fa452bd2ecb42224559a49f5880b0 diff --git a/ansible/roles/geerlingguy.nodejs b/ansible/roles/geerlingguy.nodejs deleted file mode 160000 index f9f23697..00000000 --- a/ansible/roles/geerlingguy.nodejs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f9f23697e4c47f170b3ddca6956e85984a4bc0b0 diff --git a/ansible/roles/geerlingguy.php b/ansible/roles/geerlingguy.php deleted file mode 160000 index 377516f0..00000000 --- a/ansible/roles/geerlingguy.php +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 377516f0f5939c5558008b270f4e02ff4e89a45a diff --git a/ansible/roles/mariadb b/ansible/roles/mariadb deleted file mode 160000 index 675b89ca..00000000 --- a/ansible/roles/mariadb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 675b89ca932f0b7afa15adcfc2e2674bc6b6075c diff --git a/ansible/roles/nginx/handlers/main.yml b/ansible/roles/nginx/handlers/main.yml deleted file mode 100755 index 2f13877f..00000000 --- a/ansible/roles/nginx/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: restart nginx - service: - name: nginx - enabled: yes - state: restarted \ No newline at end of file diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml deleted file mode 100755 index 8b590dd2..00000000 --- a/ansible/roles/nginx/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: ensure nginx is installed - apt: - pkg: nginx - -- name: Change default nginx site - become: yes - template: - src: default.j2 - dest: /etc/nginx/sites-available/default - notify: restart nginx diff --git a/ansible/roles/nginx/templates/default.j2 b/ansible/roles/nginx/templates/default.j2 deleted file mode 100755 index a07daa39..00000000 --- a/ansible/roles/nginx/templates/default.j2 +++ /dev/null @@ -1,25 +0,0 @@ -server { - listen 80; - - root /vagrant/public; - index index.php; - - location / { - try_files $uri /index.php$is_args$args; - } - - error_page 404 /404.html; - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/www; - } - - location ~ ^/index\.php(/|$) { - fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php{{ php_default_version_debian }}-fpm.sock; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param HTTPS off; - } -} diff --git a/ansible/roles/oefenweb.yarn b/ansible/roles/oefenweb.yarn deleted file mode 160000 index fd876cac..00000000 --- a/ansible/roles/oefenweb.yarn +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fd876cacdc8ad13f7aebdfa905495dabd1082e15 diff --git a/ansible/roles/systemli.dovecot b/ansible/roles/systemli.dovecot deleted file mode 160000 index bd8f66c5..00000000 --- a/ansible/roles/systemli.dovecot +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bd8f66c57c67156165b0ce62b756a0ab6acbc11f diff --git a/docs/development/index.md b/docs/development/index.md index d40aab91..ebb30c0b 100644 --- a/docs/development/index.md +++ b/docs/development/index.md @@ -1,85 +1,61 @@ -# Development +# Getting started -## Development with Vagrant +The easiest way to get started with Userli is to use podman or docker. +We provide a `docker-compose.yml` file that starts Userli, Dovecot and MariaDB. -### Requirements +!!! info + If you don't have podman or docker installed, you can find the installation instructions on the [podman website](https://podman.io/getting-started/installation) or the [docker website](https://docs.docker.com/get-docker/). -- [Vagrant](https://vagrantup.com/) to set up a virtual machine as development environment. -- [VirtualBox](https://www.virtualbox.org/) as a [virtualisation provider](https://developer.hashicorp.com/vagrant/docs/providers/virtualbox) for Vagrant. -- [Ansible](https://www.ansible.com/) for provisioning the virtual machine. -!!! note +Start Userli, Dovecot and MariaDB with podman or docker: - The provisioning of the development environment is defined in `.Vagrantfile` and `.ansible/playbook.yml`. - If you're unfamiliar with Vagrant, you might want to check out its [Quick Start guide](https://developer.hashicorp.com/vagrant/tutorials/getting-started). +=== "podman" -### Start Vagrant box + ```shell + podman compose up -d + ``` -````shell -# pull ansible roles for provisioning: -git submodule update --init +=== "docker" -# start vagrant box. -# Implies "vagrant up --provision" when run for first time -vagrant up + ```shell + docker compose up -d + ``` -## ssh into the virtual environment -vagrant ssh - -# create database and schema -bin/console doctrine:schema:create - -# get node modules -yarn - -# update assets -yarn encore dev -```` - -Visit you local instance at [http://192.168.60.99/](http://192.168.60.99). - -## Development on macOS - -### Requirements - -- [Homebrew](https://brew.sh/index_de) -- [Docker](https://www.docker.com/) - -### Start the environment +Install dependencies and run composer scripts: ```shell -# spin up mariadb -docker-compose up -d +composer install --ignore-platform-reqs +``` -brew install php@8.0 -export PATH="/opt/homebrew/opt/php@8.0/bin:$PATH" +Initialize the database: -# install dependencies and run composer scripts -composer install --ignore-platform-reqs +=== "podman" -# create database and schema -bin/console doctrine:schema:create + ```shell + podman compose exec userli bin/console doctrine:schema:create + ``` -# get node modules -yarn +=== "docker" + ```shell + docker compose exec userli bin/console doctrine:schema:create + ``` -# update assets -yarn encore dev +Install sample data: -# start the server -bin/console server:run -``` +=== "podman" + ```shell + podman compose exec userli bin/console doctrine:fixtures:load + ``` -## Install sample data +=== "docker" + ```shell + docker compose exec userli bin/console doctrine:fixtures:load + ``` -```shell -bin/console doctrine:fixtures:load -``` +Open your browser and go to [http://localhost:8000](http://localhost:8000) -The `doctrine:fixtures:load` command will create four new accounts with -corresponding roles (`admin`, `user`, `support`, `suspicious`) as well -as some random aliases and vouchers. The domain for all accounts is -"example.org" and the password is "password". -If you want to see more details about how the users are created, see -`src/DataFixtures`. +!!! info + The `doctrine:fixtures:load` command will create four new accounts with corresponding roles (`admin`, `user`, `support`, `suspicious`) as well as some random aliases and vouchers. The domain for all accounts is "example.org" and the password is "password". + + If you want to see more details about how the users are created, see `src/DataFixtures`. diff --git a/docs/development/tests.md b/docs/development/tests.md index 2ba2275b..d8307600 100644 --- a/docs/development/tests.md +++ b/docs/development/tests.md @@ -1,25 +1,27 @@ # Tests -## Linting, unit tests and functional tests -```shell -vagrant up && vagrant ssh -make test -make integration -``` +Create sample test data: -## Test checkpassword script +=== "podman" + ```shell + podman compose exec userli bin/console doctrine:fixtures:load --group=basic --env=test --no-interaction + ``` -```shell -# Start vagrant box and login -vagrant up && vagrant ssh -# Create DB schema and load fixtures -bin/console doctrine:schema:create -bin/console doctrine:fixture:load -# Run `app:users:checkpassword` locally. First should return `0`, second `1` -echo -en 'user@example.org\0password' | ./bin/console app:users:checkpassword /bin/true; echo $? -echo -en 'user@example.org\0wrong' | ./bin/console app:users:checkpassword /bin/true; echo $? -# Logout from vagrant and test via IMAP login -exit -./tests/test_checkpassword_login.sh -``` +=== "docker" + ```shell + docker compose exec userli bin/console doctrine:fixtures:load --group=basic --env=test --no-interaction + ``` + +Run tests: + +=== "podman" + ```shell + podman compose exec userli bin/phpunit + ``` + +=== "docker" + ```shell + docker compose exec userli bin/phpunit + ``` + diff --git a/docs/getting-started/index.md b/docs/getting-started/index.md deleted file mode 100644 index 70092256..00000000 --- a/docs/getting-started/index.md +++ /dev/null @@ -1,38 +0,0 @@ -# Getting Started - -The easiest way to get started with Userli is to use podman or docker. -We provide a `docker-compose.yml` file that starts Userli and MariaDB. -This is not recommended for production use, but it is a good way to get started. - -!!! info - If you don't have podman or docker installed, you can find the installation instructions on the [podman website](https://podman.io/getting-started/installation) or the [docker website](https://docs.docker.com/get-docker/). - -1. Start Userli and MariaDB with podman or docker: - - Using podman: - - ```shell - podman compose up -d - ``` - - Using docker: - - ```shell - docker compose up -d - ``` - -2. Initialize the database: - - Using podman: - - ```shell - podman compose exec userli bin/console doctrine:schema:create - ``` - - Using docker: - - ```shell - docker compose exec userli bin/console doctrine:schema:create - ``` - -3. Open your browser and go to [http://localhost:8000](http://localhost:8000) diff --git a/docs/installation/webserver.md b/docs/installation/webserver.md index 591677fc..0b60f1cb 100644 --- a/docs/installation/webserver.md +++ b/docs/installation/webserver.md @@ -24,7 +24,7 @@ rewrite { server { listen 80; - root /vagrant/public; + root /var/www/userli/public; index index.php; location / { diff --git a/mkdocs.yml b/mkdocs.yml index cb196d52..2e3bca5e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -6,12 +6,11 @@ repo_url: https://github.com/systemli/userli nav: - Home: index.md - Development: - - Development: development/index.md + - "Getting started": development/index.md - "Code of Conduct": development/code_of_conduct.md - Icons: development/icons.md - Release: development/release.md - Tests: development/tests.md - - "Getting started": getting-started/index.md - Installation: - Installation: installation/index.md - Checkpassword: installation/checkpassword.md @@ -35,6 +34,7 @@ theme: - content.code.copy - content.code.select - content.code.annotate + - content.tabs.link - navigation.tabs - navigation.tabs.sticky - navigation.sections @@ -54,7 +54,10 @@ extra: markdown_extensions: - admonition + - pymdownx.details - pymdownx.highlight - pymdownx.inlinehilite - pymdownx.snippets - pymdownx.superfences + - pymdownx.tabbed: + alternate_style: true \ No newline at end of file