From 880cb6016c3f7b787ce44d0198acb591f4f10a5f Mon Sep 17 00:00:00 2001 From: Sebastian Castro Date: Thu, 21 Dec 2023 16:25:22 +0100 Subject: [PATCH 1/9] docker: fix documentation --- INSTALL.md | 15 +++++++-------- docker/README.md | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 5d97fdebd..7c4c756a5 100755 --- a/INSTALL.md +++ b/INSTALL.md @@ -25,13 +25,12 @@ Detailed instructions are available [in the official doc](https://yeswiki.net/?d First you need to install docker and docker-compose: -Run `docker-compose up` in the root folder to install and launch the containers +Run `cd docker && docker compose up -d` to install and launch the containers -Then go to . -In the setup, you will need to provide following configuration for MySQL server: +Then go to . +In the setup, you will need to provide following configuration for the database: -- **Host: db** -- Login: root -- Password: root - -You can see/modify the created tables by going to: +- MySQL Host: yeswiki-db +- MySql Database: yeswiki (see `docker/yeswiki.secrets`) +- MySql Username: yeswiki (see `docker/yeswiki.secrets`) +- MySql Password: password (see `docker/yeswiki.secrets``) diff --git a/docker/README.md b/docker/README.md index 6e24b3f0d..bbf836844 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,6 +2,8 @@ ## Build image +From within `docker` folder + ```bash docker compose build ``` @@ -15,7 +17,7 @@ docker compose build - allow www-data to right local directory This version should map the local repository to your docker container. -- `docker compose up -f docker-compose-dev.yml` +- `docker compose -f docker-compose-dev.yml up` ## Remove all docker images and volumes From 825d729a70836e85e517d34a242fcffd21bd1ad0 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 26 Dec 2023 18:05:19 +0100 Subject: [PATCH 2/9] WIP add working dev docker-compose for all architecture didn't test maildev for now. --- cache/README.md | 5 - docker/README.md | 65 ++++++++++--- ...ompose-dev.yml => docker-compose-prod.yml} | 2 + docker/docker-compose.yml | 93 ++++++++++++------- docker/dockerfile | 44 ++++----- docker/dockerfile-prod | 34 +++++++ docker/dockerfile_test.yml | 27 ++++++ docker/entrypoint.sh | 8 ++ docker/nginx.conf | 4 +- 9 files changed, 201 insertions(+), 81 deletions(-) delete mode 100644 cache/README.md rename docker/{docker-compose-dev.yml => docker-compose-prod.yml} (96%) create mode 100644 docker/dockerfile-prod create mode 100644 docker/dockerfile_test.yml create mode 100755 docker/entrypoint.sh diff --git a/cache/README.md b/cache/README.md deleted file mode 100644 index c53f60bce..000000000 --- a/cache/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Cache directory - -The folder `cache` contains image thumbs and not permanent content. -You can delete its content without risks (in theory). - diff --git a/docker/README.md b/docker/README.md index bbf836844..95eb93874 100644 --- a/docker/README.md +++ b/docker/README.md @@ -4,25 +4,62 @@ From within `docker` folder -```bash -docker compose build + - create a file `.env` with the following value :  + + +``` +export UID="YOUR_USER_ID" # can be found with id -u +export GID="YOUR_USER_GID" # can be found with id -g + +``` + - copy the file `yeswiki.secret.example` to `yeswiki.secret` + - build the container ``` +docker compose build +``` + - launch image +``` +docker compose up -d +``` + +It should take some time for the first launch, it will perform `compose install` and `yarn install`. +then yeswiki will be accessible at `localhost:8085`, phpmyadmin at `localohost:8086` and mailcatcher at `localhost:1080` -## Launch image +Once on the install page, use the following values : -- `docker compose up -d` -- yeswiki should be accessible at `localhost:8085` +- **Mysql server host** : yeswiki-db +- **MYSQL database name** : yeswiki (can be fond in yeswiki.secret) +- **MYSQL username** : yeswiki (can be fond in yeswiki.secret) +- **MYSQL password** : password (can be fond in yeswiki.secret) -## Dev version +> [!]tips +> if you have a previous developpement installation you may need to change value accordingly in the wakka.config.php -- allow www-data to right local directory - This version should map the local repository to your docker container. -- `docker compose -f docker-compose-dev.yml up` +## reinitialize yeswiki repo from dev -## Remove all docker images and volumes +docker create and populates the following folders files : -```bash -docker compose stop -docker compose rm -docker volume rm yeswiki yeswiki-db +- vendor (for php dependencies) +- node_modules (for yarn dependencies) +- wakka.config.php +- cache +- tools/bazar/vendor/ + +## Remove database + +- remove containers +``` +docker compose down +``` +- remove docker volume +``` +docker volume rm yeswiki-db +``` + +## updating php or yarn dependency + +``` +docker compose exec yeswiki-app bash +composer install +yarn install ``` diff --git a/docker/docker-compose-dev.yml b/docker/docker-compose-prod.yml similarity index 96% rename from docker/docker-compose-dev.yml rename to docker/docker-compose-prod.yml index 6aa8c46a7..275460a87 100644 --- a/docker/docker-compose-dev.yml +++ b/docker/docker-compose-prod.yml @@ -3,6 +3,8 @@ version: "3.7" volumes: yeswiki-db: name: yeswiki-db + yeswiki: + name: yeswiki networks: yeswiki: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f77fbdca4..e91f57878 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -3,45 +3,68 @@ version: "3.7" volumes: yeswiki-db: name: yeswiki-db - yeswiki: - name: yeswiki networks: yeswiki: services: - yeswiki-app: - build: - context: .. - dockerfile: ./docker/dockerfile - container_name: yeswiki - volumes: - - yeswiki:/var/www/html - depends_on: - - yeswiki-db - env_file: ./yeswiki.secrets - networks: - - yeswiki + yeswiki-app: + build: + context: .. + dockerfile: ./docker/dockerfile + args: + UID: "${UID:-1000}" + GID: "${UIS:-1000}" + container_name: yeswiki + volumes: + - ..:/var/www/html + depends_on: + - yeswiki-db + env_file: ./yeswiki.secrets + user: "${UID}:${UID}" + command: /var/www/html/docker/entrypoint.sh + networks: + - yeswiki - yeswiki-db: - image: mysql:latest - container_name: yeswiki-db - volumes: - - yeswiki-db:/var/lib/mysql - env_file: ./yeswiki.secrets - networks: - - yeswiki - restart: unless-stopped + yeswiki-db: + image: mysql:latest + container_name: yeswiki-db + volumes: + - yeswiki-db:/var/lib/mysql + env_file: ./yeswiki.secrets + networks: + - yeswiki + + yeswiki-web: + image: nginx:alpine + container_name: yeswiki-web + volumes: + - ..:/var/www/html:ro + - ./nginx.conf:/etc/nginx/nginx.conf:ro + ports: + - "8085:80" + depends_on: + - yeswiki-app + - myadmin + networks: + - yeswiki + + myadmin: + image: phpmyadmin:latest + container_name: myadmin + env_file: ./yeswiki.secrets + environment: + PMA_HOST: yeswiki-db + PMA_PORT: 3306 + ports: + - "8086:80" + networks: + - yeswiki - yeswiki-web: - image: nginx:alpine - container_name: yeswiki-web - volumes: - - yeswiki:/var/www/html:ro - - ./nginx.conf:/etc/nginx/nginx.conf:ro - ports: - - "8085:80" - depends_on: - - yeswiki-app - networks: - - yeswiki + mail: + image: maildev/maildev + container_name: mail + ports: + - "1080:1080" + networks: + - yeswiki diff --git a/docker/dockerfile b/docker/dockerfile index d264e6a3b..434d31903 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -1,34 +1,28 @@ -# download composer dependencies -FROM composer:2.1.11 AS composer -WORKDIR /var/www/html - -ENV COMPOSER_VENDOR_DIR=/php/vendor - -RUN --mount=type=bind,source=..,target=.,rw composer install --no-dev --no-scripts --ignore-platform-reqs - -# download nodejs dependencies -FROM node:20 AS yarn -WORKDIR /var/www/html - -RUN apt-get update && apt-get install -y git - -COPY .. . - -RUN yarn install - - -# Yeswiki image +# Yeswiki dev image FROM php:8.2-fpm -RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev && \ +RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev git unzip && \ rm -rf /var/lib/apt/lists/* RUN docker-php-ext-install mysqli gd zip -COPY . /var/www/html/ +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +ARG UID + +ARG GID + +RUN groupadd -g "${UID}" yeswiki \ + && useradd --no-log-init --create-home -u "${UID}" -g "${UID}" -g www-data yeswiki -COPY --from=composer /php/vendor /var/www/html/vendor/ -COPY --from=yarn /var/www/html/node_modules/ /var/www/html/node_modules/ +USER yeswiki -RUN chown -R www-data:www-data /var/www/html/ +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash && \ + export NVM_DIR="$HOME/.nvm" && \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + echo 'export NVM_DIR="/home/yeswiki/.nvm"' >> $HOME/.bashrc && \ + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.bashrc && \ + nvm install 20 && \ + nvm alias default 20 && \ + corepack enable diff --git a/docker/dockerfile-prod b/docker/dockerfile-prod new file mode 100644 index 000000000..d264e6a3b --- /dev/null +++ b/docker/dockerfile-prod @@ -0,0 +1,34 @@ + +# download composer dependencies +FROM composer:2.1.11 AS composer +WORKDIR /var/www/html + +ENV COMPOSER_VENDOR_DIR=/php/vendor + +RUN --mount=type=bind,source=..,target=.,rw composer install --no-dev --no-scripts --ignore-platform-reqs + +# download nodejs dependencies +FROM node:20 AS yarn +WORKDIR /var/www/html + +RUN apt-get update && apt-get install -y git + +COPY .. . + +RUN yarn install + + +# Yeswiki image +FROM php:8.2-fpm + +RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev && \ + rm -rf /var/lib/apt/lists/* + +RUN docker-php-ext-install mysqli gd zip + +COPY . /var/www/html/ + +COPY --from=composer /php/vendor /var/www/html/vendor/ +COPY --from=yarn /var/www/html/node_modules/ /var/www/html/node_modules/ + +RUN chown -R www-data:www-data /var/www/html/ diff --git a/docker/dockerfile_test.yml b/docker/dockerfile_test.yml new file mode 100644 index 000000000..c80a08a7e --- /dev/null +++ b/docker/dockerfile_test.yml @@ -0,0 +1,27 @@ +# download composer dependencies +FROM composer:2.1.11 AS composer +WORKDIR /var/www/html + +COPY .. . + +RUN composer install --no-dev --no-scripts --ignore-platform-reqs + +# download nodejs dependencies +FROM node:20 AS yarn +WORKDIR /var/www/html + +RUN apt-get update && apt-get install -y git + +COPY --from=composer /var/www/html /var/www/html + +RUN yarn install + + +# Yeswiki image +FROM php:8.2-fpm + +RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev && \ + rm -rf /var/lib/apt/lists/* + +RUN docker-php-ext-install mysqli gd zip +COPY --from=yarn --chown=www-data:www-data /var/www/html /var/www/html diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 000000000..bcbedc333 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd /var/www/html +composer install +source /home/yeswiki/.nvm/nvm.sh +nvm use 20 +corepack enable +yarn install +php-fpm diff --git a/docker/nginx.conf b/docker/nginx.conf index 9e07f36a6..34743edbf 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -28,13 +28,11 @@ http { set_real_ip_from 192.168.0.0/16; real_ip_header X-Real-IP; - #gzip on; upstream php-handler { server yeswiki-app:9000; } - server { listen 80; @@ -112,4 +110,6 @@ http { access_log off; } } + } + From 4265552ca36ce22b70d6c239ef1f97a23cdaeb25 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 26 Dec 2023 18:05:19 +0100 Subject: [PATCH 3/9] WIP add working dev docker-compose for all architecture didn't test maildev for now. --- docker/README.md | 67 ++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/docker/README.md b/docker/README.md index 95eb93874..6e24b3f0d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,64 +2,25 @@ ## Build image -From within `docker` folder - - - create a file `.env` with the following value :  - - -``` -export UID="YOUR_USER_ID" # can be found with id -u -export GID="YOUR_USER_GID" # can be found with id -g - +```bash +docker compose build ``` - - copy the file `yeswiki.secret.example` to `yeswiki.secret` - - build the container -``` -docker compose build -``` - - launch image -``` -docker compose up -d -``` - -It should take some time for the first launch, it will perform `compose install` and `yarn install`. -then yeswiki will be accessible at `localhost:8085`, phpmyadmin at `localohost:8086` and mailcatcher at `localhost:1080` -Once on the install page, use the following values : +## Launch image -- **Mysql server host** : yeswiki-db -- **MYSQL database name** : yeswiki (can be fond in yeswiki.secret) -- **MYSQL username** : yeswiki (can be fond in yeswiki.secret) -- **MYSQL password** : password (can be fond in yeswiki.secret) +- `docker compose up -d` +- yeswiki should be accessible at `localhost:8085` -> [!]tips -> if you have a previous developpement installation you may need to change value accordingly in the wakka.config.php +## Dev version -## reinitialize yeswiki repo from dev +- allow www-data to right local directory + This version should map the local repository to your docker container. +- `docker compose up -f docker-compose-dev.yml` -docker create and populates the following folders files : +## Remove all docker images and volumes -- vendor (for php dependencies) -- node_modules (for yarn dependencies) -- wakka.config.php -- cache -- tools/bazar/vendor/ - -## Remove database - -- remove containers -``` -docker compose down -``` -- remove docker volume -``` -docker volume rm yeswiki-db -``` - -## updating php or yarn dependency - -``` -docker compose exec yeswiki-app bash -composer install -yarn install +```bash +docker compose stop +docker compose rm +docker volume rm yeswiki yeswiki-db ``` From 875099dc82f2bb670d9cf16e515550d50190e922 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Thu, 4 Jan 2024 14:54:26 +0100 Subject: [PATCH 4/9] working docker compose add documentation --- INSTALL.md | 12 +------ docker/README.md | 92 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 79 insertions(+), 25 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 7c4c756a5..f2dbc469b 100755 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,14 +23,4 @@ Detailed instructions are available [in the official doc](https://yeswiki.net/?d ## Installation through Docker -First you need to install docker and docker-compose: - -Run `cd docker && docker compose up -d` to install and launch the containers - -Then go to . -In the setup, you will need to provide following configuration for the database: - -- MySQL Host: yeswiki-db -- MySql Database: yeswiki (see `docker/yeswiki.secrets`) -- MySql Username: yeswiki (see `docker/yeswiki.secrets`) -- MySql Password: password (see `docker/yeswiki.secrets``) +Instructions can be found [here](./docker/README.md) diff --git a/docker/README.md b/docker/README.md index 6e24b3f0d..0a3e182aa 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,26 +1,90 @@ # Docker usage -## Build image +This directory contain 2 dockerfiles and 2 docker-compose. One of each for dev and the other for production. -```bash +## Dev + +The dev docker-compose contain the following images : + + - yeswiki-app: This image have only a php-fpm process and mount the directory in the container to be able to develop locally + - yeswiki-db : a mysql (mariadb seems to not work properly currently) accessible from yeswiki with domaine name `yeswiki-db` + - yeswiki-web : a nginx reverse-proxy. configuration can be found on nginx.conf file. Accessible on `localhost:8085` + - myadmin : phpmyadmin accessible on `localhost:8086` + - mail : container to intercept email send by yeswiki. Webmail is accessible on `localhost:1080`.You have to set the following in `wakka.config.php` + ``` +'contact_mail_func' => 'smtp', +'contact_smtp_host' => 'mail', +'contact_smtp_port' => '1025', + ``` +### How-To + +> [!]info +> all commands have to be launched from docker directory + +To be able to develop locally without messing up with users and permissions, the dev dockerfile uses the same user and group as computer user. +You need to create a file called `.env` within the `docker` directory with the following content : +``` +export UID="YOUR_USER_ID" # can be found with id -u +export GID="YOUR_USER_GID" # can be found with id -g +``` + +Then you can build the container with the following command : +``` docker compose build ``` -## Launch image +Once done, you can start containers : +``` +docker compose up +# or docker compose up -d if you want to detach from terminal +``` + +It should take some time for the first launch, it will perform `compose install` and `yarn install`. +Then yeswiki will be accessible at [localhost:8085](http://localhost:8085), + phpmyadmin at [localohost:8086](http://localhost:8086) and mailcatcher at [localhost:1080](http://localhost:1080). + +Once on the install page, use the following values : + +- **Mysql server host** : yeswiki-db +- **MYSQL database name** : yeswiki (can be fond in yeswiki.secret) +- **MYSQL username** : yeswiki (can be fond in yeswiki.secret) +- **MYSQL password** : password (can be fond in yeswiki.secret) -- `docker compose up -d` -- yeswiki should be accessible at `localhost:8085` +> [!]tips +> if you have a previous developpement installation you may need to change value accordingly in the wakka.config.php -## Dev version +## reinitialize yeswiki repo from dev -- allow www-data to right local directory - This version should map the local repository to your docker container. -- `docker compose up -f docker-compose-dev.yml` +docker create and populates the following folders files : -## Remove all docker images and volumes +- vendor (for php dependencies) +- node_modules (for yarn dependencies) +- wakka.config.php +- cache +- tools/bazar/vendor/ -```bash -docker compose stop -docker compose rm -docker volume rm yeswiki yeswiki-db +It should be enough to remove the `wakka.config.php` file + +## Remove database + +- remove containers (stopping container doesn't remove them) +``` +docker compose down +``` +- remove docker volume (containing database files) +``` +docker volume rm yeswiki-db +``` + +## updating php or yarn dependency + +You can simply restart container with the following command :  +``` +docker compose restart +``` + +If you want to update php or yarn dependency without restarting everything, you can do the following commands. +``` +docker compose exec yeswiki-app composer install +docker compose exec yeswiki-app yarn install ``` From 5a4c2087509a74ac4c75407f4585d3fea3959f91 Mon Sep 17 00:00:00 2001 From: 12b Date: Thu, 21 Mar 2024 11:57:05 +0100 Subject: [PATCH 5/9] fix(docker): remove version attr in docker_compose and doc improvements --- docker/README.md | 10 +++++----- docker/docker-compose-prod.yml | 2 -- docker/docker-compose.yml | 2 -- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/docker/README.md b/docker/README.md index 0a3e182aa..7ecab1bc8 100644 --- a/docker/README.md +++ b/docker/README.md @@ -24,8 +24,8 @@ The dev docker-compose contain the following images : To be able to develop locally without messing up with users and permissions, the dev dockerfile uses the same user and group as computer user. You need to create a file called `.env` within the `docker` directory with the following content : ``` -export UID="YOUR_USER_ID" # can be found with id -u -export GID="YOUR_USER_GID" # can be found with id -g +UID="YOUR_USER_ID" # can be found with id -u +GID="YOUR_USER_GID" # can be found with id -g ``` Then you can build the container with the following command : @@ -46,9 +46,9 @@ Then yeswiki will be accessible at [localhost:8085](http://localhost:8085), Once on the install page, use the following values : - **Mysql server host** : yeswiki-db -- **MYSQL database name** : yeswiki (can be fond in yeswiki.secret) -- **MYSQL username** : yeswiki (can be fond in yeswiki.secret) -- **MYSQL password** : password (can be fond in yeswiki.secret) +- **MYSQL database name** : yeswiki (can be found in yeswiki.secret) +- **MYSQL username** : yeswiki (can be found in yeswiki.secret) +- **MYSQL password** : password (can be found in yeswiki.secret) > [!]tips > if you have a previous developpement installation you may need to change value accordingly in the wakka.config.php diff --git a/docker/docker-compose-prod.yml b/docker/docker-compose-prod.yml index 275460a87..f0a4cfe7c 100644 --- a/docker/docker-compose-prod.yml +++ b/docker/docker-compose-prod.yml @@ -1,5 +1,3 @@ -version: "3.7" - volumes: yeswiki-db: name: yeswiki-db diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e91f57878..b96ec4f49 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.7" - volumes: yeswiki-db: name: yeswiki-db From 8b55bf0052d5031753aad64d6797693a702daf3d Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Thu, 21 Mar 2024 18:55:50 +0300 Subject: [PATCH 6/9] fix(docker): good GID and format --- docker/dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docker/dockerfile b/docker/dockerfile index 434d31903..adcece541 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -3,7 +3,7 @@ FROM php:8.2-fpm RUN apt-get update && apt-get install -y libpng-dev libzlcore-dev libzip-dev git unzip && \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/* RUN docker-php-ext-install mysqli gd zip @@ -13,16 +13,16 @@ ARG UID ARG GID -RUN groupadd -g "${UID}" yeswiki \ - && useradd --no-log-init --create-home -u "${UID}" -g "${UID}" -g www-data yeswiki +RUN groupadd -g "${GID}" yeswiki \ + && useradd --no-log-init --create-home -u "${UID}" -g "${GID}" -G www-data yeswiki USER yeswiki RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash && \ - export NVM_DIR="$HOME/.nvm" && \ - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ - echo 'export NVM_DIR="/home/yeswiki/.nvm"' >> $HOME/.bashrc && \ - echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.bashrc && \ - nvm install 20 && \ - nvm alias default 20 && \ - corepack enable + export NVM_DIR="$HOME/.nvm" && \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + echo 'export NVM_DIR="/home/yeswiki/.nvm"' >> $HOME/.bashrc && \ + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.bashrc && \ + nvm install 20 && \ + nvm alias default 20 && \ + corepack enable From e18d0edf2b78d3262efeae0d596ebec0c9774627 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Thu, 21 Mar 2024 22:14:33 +0300 Subject: [PATCH 7/9] fix(CI) : docker build with env vars UID and GID --- .github/workflows/docker.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d6493eaf2..2c79a2104 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,14 +3,14 @@ name: Docker Image on: push: paths: - - docker/dockerfile - - docker/docker-compose*.yml + - docker/dockerfile + - docker/docker-compose*.yml jobs: build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Build a Docker image able to run yeswiki - run: docker build -f docker/dockerfile -t yeswiki/yeswiki . + - name: Build a Docker image able to run yeswiki + run: export UID=$(id -u) && export GID=$(id -g) && docker build -f docker/dockerfile -t yeswiki/yeswiki . From 145f2fc8d3cab802469b8991c8684056fd293b41 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Thu, 21 Mar 2024 22:29:38 +0300 Subject: [PATCH 8/9] fix(CI) : attempt to create cache folder --- .github/workflows/phpunit-php73.yml | 188 ++++++++++++++-------------- 1 file changed, 95 insertions(+), 93 deletions(-) diff --git a/.github/workflows/phpunit-php73.yml b/.github/workflows/phpunit-php73.yml index 65d0bfea2..c8b795530 100644 --- a/.github/workflows/phpunit-php73.yml +++ b/.github/workflows/phpunit-php73.yml @@ -4,23 +4,23 @@ on: workflow_dispatch: inputs: logLevel: - description: 'Log level' + description: "Log level" required: true - default: 'warning' + default: "warning" tags: - description: 'Tags' + description: "Tags" push: - branches: [ doryphore, ectoplasme ] + branches: [doryphore, ectoplasme] paths: - - 'composer.lock' - - '*.php' - - '.github/workflows/*.yml' + - "composer.lock" + - "*.php" + - ".github/workflows/*.yml" pull_request: - branches: [ doryphore, doryphore-dev, ectoplasme ] + branches: [doryphore, doryphore-dev, ectoplasme] paths: - - 'composer.lock' - - '*.php' - - '.github/workflows/*.yml' + - "composer.lock" + - "*.php" + - ".github/workflows/*.yml" env: DB_NAME: yeswiki_test @@ -30,85 +30,87 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - uses: shivammathur/setup-php@v2 - with: - php-version: '7.3' - extensions: mysqli - tools: composer:v2 - env: - fail-fast: true - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - - name: Configures and starts Apache - run: | - echo " - ServerName localhost - DocumentRoot ${{ github.workspace }} - - - Options FollowSymLinks MultiViews ExecCGI - AllowOverride All - Require all granted - - " | sudo tee /etc/apache2/sites-enabled/000-default.conf - sudo chown www-data:www-data -R ${{ github.workspace }} - sudo apt update - sudo apt install --no-install-recommends --assume-yes libapache2-mod-php7.3 - sudo a2enmod php7.3 - sudo /etc/init.d/apache2 start - - - name: Set up MySQL - run: | - sudo /etc/init.d/mysql start - mysql -e 'CREATE DATABASE ${{ env.DB_NAME }};' -uroot -proot - - - name: Append current user in www-data group - run: | - sudo usermod -aG www-data $USER - - - name: Set cache folder writable - run: sudo chmod -R 0777 ${{ github.workspace }}/cache - - - name: Set private folder for archive (and clean previous files) - run: | - sudo mkdir -p ${{ github.workspace }}/private/archives - sudo chown www-data:www-data -R ${{ github.workspace }}/private/archives - sudo chmod -R 0777 ${{ github.workspace }}/private/archives - sudo ls ${{ github.workspace }}/private/archives/* && sudo rm ${{ github.workspace }}/private/archives/* || true - - - run: curl http://localhost - - - name: Setup Wiki - run: | - curl --silent --fail --show-error \ - -F "config[default_language]=fr" \ - -F "config[wakka_name]=MyTestWiki" \ - -F "config[root_page]=PagePrincipale" \ - -F "config[base_url]=http://localhost/?" \ - -F "config[mysql_host]=localhost" \ - -F "config[mysql_database]=${{ env.DB_NAME }}" \ - -F "config[mysql_user]=root" \ - -F "config[mysql_password]=root" \ - -F "config[table_prefix]=yeswiki_" \ - -F "config[allow_raw_html]=1" \ - -F "config[archive][privatePath]=${{ github.workspace }}/private/archives" \ - -F "admin_name=ActionTest" \ - -F "admin_password=ActionTestPassword" \ - -F "admin_password_conf=ActionTestPassword" \ - -F "admin_email=test@example.com" \ - -F "submit=Continue" \ - "http://localhost/?PagePrincipale&installAction=install" - - - name: Set wakka.config.php writable - run: | - sudo chown www-data:www-data ${{ github.workspace }}/wakka.config.php - sudo chmod 0777 ${{ github.workspace }}/wakka.config.php - - - name: Run test suite - run: composer test + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: "7.3" + extensions: mysqli + tools: composer:v2 + env: + fail-fast: true + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Configures and starts Apache + run: | + echo " + ServerName localhost + DocumentRoot ${{ github.workspace }} + + + Options FollowSymLinks MultiViews ExecCGI + AllowOverride All + Require all granted + + " | sudo tee /etc/apache2/sites-enabled/000-default.conf + sudo chown www-data:www-data -R ${{ github.workspace }} + sudo apt update + sudo apt install --no-install-recommends --assume-yes libapache2-mod-php7.3 + sudo a2enmod php7.3 + sudo /etc/init.d/apache2 start + + - name: Set up MySQL + run: | + sudo /etc/init.d/mysql start + mysql -e 'CREATE DATABASE ${{ env.DB_NAME }};' -uroot -proot + + - name: Append current user in www-data group + run: | + sudo usermod -aG www-data $USER + + - name: Set cache folder writable + run: | + sudo mkdir -p ${{ github.workspace }}/cache + sudo chmod -R 0777 ${{ github.workspace }}/cache + + - name: Set private folder for archive (and clean previous files) + run: | + sudo mkdir -p ${{ github.workspace }}/private/archives + sudo chown www-data:www-data -R ${{ github.workspace }}/private/archives + sudo chmod -R 0777 ${{ github.workspace }}/private/archives + sudo ls ${{ github.workspace }}/private/archives/* && sudo rm ${{ github.workspace }}/private/archives/* || true + + - run: curl http://localhost + + - name: Setup Wiki + run: | + curl --silent --fail --show-error \ + -F "config[default_language]=fr" \ + -F "config[wakka_name]=MyTestWiki" \ + -F "config[root_page]=PagePrincipale" \ + -F "config[base_url]=http://localhost/?" \ + -F "config[mysql_host]=localhost" \ + -F "config[mysql_database]=${{ env.DB_NAME }}" \ + -F "config[mysql_user]=root" \ + -F "config[mysql_password]=root" \ + -F "config[table_prefix]=yeswiki_" \ + -F "config[allow_raw_html]=1" \ + -F "config[archive][privatePath]=${{ github.workspace }}/private/archives" \ + -F "admin_name=ActionTest" \ + -F "admin_password=ActionTestPassword" \ + -F "admin_password_conf=ActionTestPassword" \ + -F "admin_email=test@example.com" \ + -F "submit=Continue" \ + "http://localhost/?PagePrincipale&installAction=install" + + - name: Set wakka.config.php writable + run: | + sudo chown www-data:www-data ${{ github.workspace }}/wakka.config.php + sudo chmod 0777 ${{ github.workspace }}/wakka.config.php + + - name: Run test suite + run: composer test From 2df750ac9735aed7fbab4792608c2f4e671d7155 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Fri, 22 Mar 2024 16:28:08 +0300 Subject: [PATCH 9/9] doc(dev) : docker install + md formatter --- docs/fr/dev.md | 144 +++++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 63 deletions(-) diff --git a/docs/fr/dev.md b/docs/fr/dev.md index 08c10c927..7052dd096 100644 --- a/docs/fr/dev.md +++ b/docs/fr/dev.md @@ -5,12 +5,21 @@ !> Des bases de programmation vous seront nécessaire pour suivre ces étapes ## Installer yeswiki dans un environnement de développement local + ### Sur des machines linux base Debian + ### Par docker +Les informations détaillées sont disponibles dans le [README.md du dossier docker](../../docker/README.md). + +En résumé depuis la racine du code source de YesWiki : +`cd docker && UID=$(id -u) && GID=$(id -g) && docker compose build && docker compose up` + +Si tout s'est bien passé vous devriez pouvoir accèder a la post-installation de YesWiki sur + ## Utilisation du dossier `custom` -[filename](../en/custom-folder.md ':include') +[filename](../en/custom-folder.md ":include")