-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker #1127
Merged
Merged
Docker #1127
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
880cb60
docker: fix documentation
seballot 825d729
WIP add working dev docker-compose for all architecture
4265552
WIP add working dev docker-compose for all architecture
875099d
working docker compose
5a4c208
fix(docker): remove version attr in docker_compose and doc improvements
8b55bf0
fix(docker): good GID and format
mrflos e18d0ed
fix(CI) : docker build with env vars UID and GID
mrflos 145f2fc
fix(CI) : attempt to create cache folder
mrflos 2df750a
doc(dev) : docker install + md formatter
mrflos ad3f350
Merge branch 'doryphore-dev' into docker
mrflos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 "<VirtualHost *:80> | ||
ServerName localhost | ||
DocumentRoot ${{ github.workspace }} | ||
|
||
<Directory "${{ github.workspace }}"> | ||
Options FollowSymLinks MultiViews ExecCGI | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
</VirtualHost>" | 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 "[email protected]" \ | ||
-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 "<VirtualHost *:80> | ||
ServerName localhost | ||
DocumentRoot ${{ github.workspace }} | ||
|
||
<Directory "${{ github.workspace }}"> | ||
Options FollowSymLinks MultiViews ExecCGI | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
</VirtualHost>" | 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 "[email protected]" \ | ||
-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 : | ||
``` | ||
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 : | ||
``` | ||
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 found in yeswiki.secret) | ||
- **MYSQL username** : yeswiki (can be found in yeswiki.secret) | ||
- **MYSQL password** : password (can be found 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 | ||
``` |
4 changes: 2 additions & 2 deletions
4
docker/docker-compose-dev.yml → docker/docker-compose-prod.yml
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. je crois que ce fichier devrait appeler le docker-prod non? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
version: "3.7" | ||
|
||
volumes: | ||
yeswiki-db: | ||
name: yeswiki-db | ||
yeswiki: | ||
name: yeswiki | ||
|
||
networks: | ||
yeswiki: | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chez moi ces commandes ne fonctionnent pas
OCI runtime exec failed: exec failed: unable to start container process: exec: "yarn install": executable file not found in $PATH: unknown
Aussi, si je me connecte au container avec un
docker compose exec yeswiki-web bash
et que ensuite je fait un yarn ou un composer, la commande se lance mais échoue à cause de problèmes de permissionsyarn install
=>error Error: EACCES: permission denied, unlink '/var/www/html/node_modules/@babel/parser/CHANGELOG.md'
composer install
=>In Filesystem.php line 288:=Could not delete /var/www/html/vendor/bin/carbon:
alors que dpeuis le entrypoint ça fonctionne. (Ps: j'ai bien créé un docker/.env avec mon user id & gorup)