Skip to content

Commit

Permalink
Merge branch '10.0/bugfixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jun 20, 2024
2 parents 743c8b7 + 140ee72 commit 373fa33
Show file tree
Hide file tree
Showing 24 changed files with 298 additions and 114 deletions.
1 change: 0 additions & 1 deletion .devcontainer/.gitignore

This file was deleted.

25 changes: 25 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# GLPI docker devcontainers

The docker devcontainers are meant to be used by VSCode or in a Github Codespaces environment.

## Services ports

By default, the following ports are exposed:
- `8080` for the GLPI web server,
- `8025` for the Mailpit web server,
- `8090` for the Adminer web server.

You can customize these ports by creating a `.devcontainer/docker-compose.override.yaml` file.

```yaml
services:
app:
ports: !override
- "9000:80"
mailpit:
ports: !override
- "9025:8025"
adminer:
ports: !override
- "9080:8080"
```
19 changes: 8 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
{
"name": "GLPI docker devcontainer",
"dockerComposeFile": "docker-compose.yml",
"service": "php",
"workspaceFolder": "/var/www/",
"name": "GLPI docker devcontainer",
"dockerComposeFile": "docker-compose.yaml",
"service": "app",
"workspaceFolder": "/var/www/glpi",

"forwardPorts": [9080, 9090, 8025],
"portsAttributes": {
"9080": {
"forwardPorts": [8080, 8090, 8025],
"portsAttributes": {
"8080": {
"label": "GLPI"
},
"9090": {
"8090": {
"label": "Adminer"
},
"8025": {
Expand All @@ -28,9 +28,6 @@
"extensions": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug",
"eamodio.gitlens",
"devsense.composer-php-vscode",
"mrorz.language-gettext",
"mblode.twig-language-2",
"dbaeumer.vscode-eslint"
]
Expand Down
4 changes: 0 additions & 4 deletions .devcontainer/docker-compose.override.yml.dist

This file was deleted.

51 changes: 51 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
services:
app:
container_name: "glpi-app"
build:
context: "../.docker/app"
restart: "unless-stopped"
volumes:
- "..:/var/www/glpi:rw"
ports:
- "8080:80"
depends_on:
- db
extra_hosts:
- "host.docker.internal:host-gateway"

db:
container_name: "glpi-db"
image: "mariadb:11.4"
restart: "unless-stopped"
volumes:
- "db:/var/lib/mysql"
- "./initdb.sql:/docker-entrypoint-initdb.d/initdb.sql"
environment:
MARIADB_ROOT_PASSWORD: "glpi"
MARIADB_DATABASE: "glpi"
MARIADB_USER: "glpi"
MARIADB_PASSWORD: "glpi"
expose:
- "3306"

mailpit:
container_name: "glpi-mailpit"
image: "axllent/mailpit"
restart: "unless-stopped"
expose:
- "1025"
ports:
- "8025:8025"

adminer:
container_name: "glpi-adminer"
image: "adminer:latest"
restart: "unless-stopped"
ports:
- "8090:8080"
environment:
- "ADMINER_DEFAULT_SERVER=db"
command: ["php", "-S", "0.0.0.0:8080", "-t", "/var/www/html"]

volumes:
db:
60 changes: 0 additions & 60 deletions .devcontainer/docker-compose.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .devcontainer/initdb.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This SQL queries contained in this file will be executed on every database container startup.

# Required for timezones usage.
# This may be executed before automatic `glpi` user creation, so we have to create it manually.
CREATE USER IF NOT EXISTS 'glpi'@'%' IDENTIFIED BY 'glpi';
SET PASSWORD FOR 'glpi'@'%' = PASSWORD('glpi');
GRANT SELECT ON `mysql`.`time_zone_name` TO 'glpi'@'%';
57 changes: 57 additions & 0 deletions .docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# GLPI docker development environment

The docker development environment can be easilly instanciated by running the command `docker compose up -d`
from the GLPI root directory.

## Custom configuration

You can customize the docker services by creating a `docker-compose.override.yaml` file in the GLPI root directory.

## HTTP server

By default, the HTTP port is published to on the `8080` port on the host machine.
You can change it in the `docker-compose.override.yaml` file.

```yaml
services:
app:
ports: !override
- "9000:80"
```
The default uid/gid used by the docker container is `1000`. If your host user uses different uid/gid, you may encounter
file permissions issues. To prevent this, you can customize them using the corresponding build args in
the `docker-compose.override.yaml` file.

```yaml
services:
app:
build:
args:
HOST_GROUP_ID: "${HOST_GROUP_ID:-1000}"
HOST_USER_ID: "${HOST_USER_ID:-1000}"
```

### Database server

By default, the database service is not provided. You can add it in the `docker-compose.override.yaml` file.

```yaml
services:
database:
container_name: "db"
image: "mariadb:11.0"
restart: "unless-stopped"
environment:
MYSQL_ROOT_PASSWORD: "R00tP4ssw0rd"
MYSQL_DATABASE: "glpi"
MYSQL_USER: "glpi"
MYSQL_PASSWORD: "P4ssw0rd"
ports:
- "3306:3306"
volumes:
- "db:/var/lib/mysql"
volumes:
db:
```
21 changes: 21 additions & 0 deletions .docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ghcr.io/glpi-project/glpi-development-env:latest

USER root

# Workaround to make apache use same UID/GID as host user.
ARG HOST_GROUP_ID=1000
RUN groupmod --gid ${HOST_GROUP_ID} www-data
ARG HOST_USER_ID=1000
RUN usermod --uid ${HOST_USER_ID} www-data

# Allow login as www-data user and allow it to execute sudo
RUN usermod --shell /bin/bash www-data
RUN echo "www-data ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Make www-data user home persistent for cache purpose.
RUN mkdir --parents /home/www-data \
&& chown www-data:www-data /home/www-data \
&& usermod --home /home/www-data www-data
VOLUME /home/www-data

USER www-data
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ phpunit.xml
/inventory-vendors/*.json
/locales/*.mo
/inc/downstream.php
/docker-compose.override.yaml
/.devcontainer/docker-compose.override.yaml
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
app:
container_name: "glpi"
build:
context: ".docker/app"
restart: "unless-stopped"
volumes:
- ".:/var/www/glpi:rw"
ports:
- "8080:80"
extra_hosts:
- "host.docker.internal:host-gateway"
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"spin.js": "^4.1.0",
"swagger-ui-dist": "^5.17.14",
"tinycolor2": "^1.6.0",
"tinymce": "^7.1.1",
"tinymce": "^7.2.0",
"tinymce-i18n": "^24.5.8",
"vue": "^3.3.13"
},
Expand Down
9 changes: 4 additions & 5 deletions src/NotificationTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,13 @@ public function formatURL($usertype, $redirect, ?string $anchor = null)

switch ($usertype) {
case self::EXTERNAL_USER:
case self::GLPI_USER:
return "$base_url/index.php?redirect={$redirect}{$anchor}";

case self::ANONYMOUS_USER:
// No URL
// case self::ANONYMOUS_USER:
default:
// No URL
return '';

case self::GLPI_USER:
return "$base_url/index.php?redirect={$redirect}&noAUTO=1{$anchor}";
}
}

Expand Down
Loading

0 comments on commit 373fa33

Please sign in to comment.