Skip to content

Commit

Permalink
Merge pull request #5040 from docjyJ/main
Browse files Browse the repository at this point in the history
Improve the development environment
  • Loading branch information
szaimen authored Jul 26, 2024
2 parents 9029991 + 2c573b2 commit 73e4ea2
Show file tree
Hide file tree
Showing 19 changed files with 2,100 additions and 154 deletions.
1 change: 0 additions & 1 deletion .github/workflows/php-deprecation-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
run: |
set -x
cd php
composer global require wapmorgan/php-deprecation-detector dev-master
composer install
composer run php-deprecation-detector | tee -i ./phpdd.log
if grep "Total issues:" ./phpdd.log; then
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/psalm-update-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ jobs:
run: |
set -x
cd php
composer global require vimeo/psalm --prefer-dist --no-progress --dev
composer install
composer run psalm -- --monochrome --no-progress --output-format=text --update-baseline
composer run psalm:update-baseline
git clean -f lib/composer
git checkout composer.json composer.lock lib/composer
continue-on-error: true
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ jobs:
run: |
set -x
cd php
composer global require vimeo/psalm --prefer-dist --no-progress --dev
composer install
composer run psalm
6 changes: 2 additions & 4 deletions .github/workflows/twig-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
permissions:
contents: read

concurrency:
concurrency:
group: lint-twig-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

Expand All @@ -36,7 +36,5 @@ jobs:
- name: twig lint
run: |
cd php
composer require sserbin/twig-linter:@dev --no-progress --dev
composer install
chmod +x ./vendor/bin/twig-linter
./vendor/bin/twig-linter lint ./templates
composer run lint:twig
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
.DS_Store
/php/data/containers.json
/php/data/configuration.json
/php/data/backupsecret.json
.idea/
*.iml

/php/data/*
/php/session/*
!/php/data/.gitkeep
!/php/session/.gitkeep
/php/vendor

/manual-install/*.conf
!/manual-install/sample.conf
/manual-install/docker-compose.yml
Expand Down
8 changes: 0 additions & 8 deletions Containers/mastercontainer/.idea/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions Containers/mastercontainer/.idea/mastercontainer.iml

This file was deleted.

6 changes: 0 additions & 6 deletions Containers/mastercontainer/.idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions Containers/mastercontainer/.idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions Containers/mastercontainer/.idea/vcs.xml

This file was deleted.

3 changes: 0 additions & 3 deletions php/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions php/.idea/.gitignore

This file was deleted.

34 changes: 0 additions & 34 deletions php/.idea/aio.iml

This file was deleted.

8 changes: 0 additions & 8 deletions php/.idea/modules.xml

This file was deleted.

34 changes: 0 additions & 34 deletions php/.idea/php.xml

This file was deleted.

6 changes: 0 additions & 6 deletions php/.idea/vcs.xml

This file was deleted.

59 changes: 53 additions & 6 deletions php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,60 @@ This is the code for the PHP Docker controller.

## How to run

Running this locally requires Docker Engine on the same machine.
If this is the case, just execute the following command:
Running this locally requires :

### 1. Install the development environment

This project uses Composer as dependency management software. It is very similar to NPM.
The command to install all dependencies is:

```bash
composer install
```
composer install --no-dev
cd public/
php -S 0.0.0.0:8080

### 2. Access to docker socket

The `root` user has all privileges including access to the Docker socket.
But **it is not recommended to launch the local instance with full privileges**, consider the docker group for docker access without being `root`.
See https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

### 3. Run a `nextcloud-aio-mastercontainer` container

This application manages containers, including its own container.
So you need to run a `nextcloud-aio-mastercontainer` container for the application to work properly.

Here is a command to quickly launch a container :

```bash
docker run \
--rm \
--name nextcloud-aio-mastercontainer \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
nextcloud/all-in-one:latest
```

You can then access the web interface at `localhost:8080`.
### 4. Start your server

With this command you will launch the server:

```bash
# Make sure to launch this command with a user having access to the docker socket.
SKIP_DOMAIN_VALIDATION=true composer run dev
```

You can then access the web interface at http://localhost:8080.

Note: You can restart the server by preceding the command with other environment variables.

## Composer routine

| Command | Description |
|-----------------------------------------|----------------------------------------|
| `composer run dev` | Starts the development server |
| `composer run psalm` | Run Psalm static analysis |
| `composer run psalm:update-baseline` | Run Psalm with `--update-baseline` arg |
| `composer run lint` | Run PHP Syntax check |
| `composer run lint:twig` | Run Twig Syntax check |
| `composer run php-deprecation-detector` | Run PHP Deprecation Detector |


18 changes: 14 additions & 4 deletions php/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"autoload": {
"psr-4": {
"psr-4": {
"AIO\\": ["src/"]
}
},
Expand All @@ -18,10 +18,20 @@
"slim/csrf": "^1.3",
"ext-apcu": "*"
},
"require-dev": {
"sserbin/twig-linter": "@dev",
"vimeo/psalm": "^5.25",
"wapmorgan/php-deprecation-detector": "dev-master"
},
"scripts": {
"dev": [
"Composer\\Config::disableProcessTimeout",
"php -S localhost:8080 -t public"
],
"psalm": "psalm --threads=1",
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
"lint": "find . -name \\*.php -not -path './vendor/*' -exec php -l {} \\;",
"php-deprecation-detector": "find . -name \\*.php -not -path './vendor/*' -exec phpdd scan {} -n -t 8.3 \\;"
"psalm:update-baseline": "psalm --threads=1 --monochrome --no-progress --output-format=text --update-baseline",
"lint": "php -l src/*.php src/**/*.php public/index.php",
"lint:twig": "twig-linter lint ./templates",
"php-deprecation-detector": "phpdd scan -n -t 8.3 src/*.php src/**/*.php public/index.php"
}
}
Loading

0 comments on commit 73e4ea2

Please sign in to comment.