Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Contributing to GLPI Docker Images

Thank you for your interest in contributing to the GLPI Docker images project!

This guide will help you set up your local development environment to test changes.

## Prerequisites

- [Docker](https://docs.docker.com/get-docker/) installed.
- [jq](https://jqlang.github.io/jq/download/) (optional, for the download script).

## Setup Development Environment

To verify that the Docker image builds and runs correctly, you need to populate the `./glpi/sources` directory with the GLPI source code.

### 1. Download GLPI Sources

We provide a helper script to automatically fetch and extract the GLPI source code.

**Download the latest stable version ([jq required](https://jqlang.github.io/jq/download/)):**
```bash
./download_sources.sh
```

**Download a specific version (e.g. 10.0.16):**
```bash
./download_sources.sh 10.0.16
```

> **Note:** This script downloads the source code archive from GitHub into `glpi/sources`. This is required for the Docker build process (`Dockerfile` copies content from this directory).

### 2. Run the Test Environment

We provide a `docker-compose.test.yml` file designed to test the `glpi` container.

Run the stack (builds the image and starts GLPI + MariaDB):

```bash
docker compose -f docker-compose.test.yml up --build
```

### 3. Verify

Once the containers are up:
1. Check the logs to see the installation progress:
```bash
docker compose -f docker-compose.test.yml logs -f glpi
```
2. Wait for the "GLPI installation completed successfully!" message.
3. Access GLPI at [http://localhost:8080](http://localhost:8080).
- **User:** `glpi`
- **Password:** `glpi`

### 4. Cleanup

To stop and remove the test containers:
```bash
docker compose -f docker-compose.test.yml down -v
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A few links:

- [Report an issue](https://github.com/glpi-project/glpi/issues/new?template=bug_report.yml)
- [Documentation](https://glpi-project.org/documentation/)
- [Contributing](CONTRIBUTING.md)


This repository contains build files for docker images available in [Github Container Registry](https://github.com/orgs/glpi-project/packages?ecosystem=container) and [Docker hub](https://hub.docker.com/r/glpi/glpi).
Expand Down
43 changes: 43 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: glpi_docker_dev

services:
glpi:
build:
context: ./glpi
restart: "no"
volumes:
# Using a named volume avoids permission issues on host (automatically managed by Docker)
- glpi_data:/var/glpi
environment:
- GLPI_DB_HOST=db
- GLPI_DB_NAME=glpi
- GLPI_DB_USER=glpi
- GLPI_DB_PASSWORD=glpi
- GLPI_DB_PORT=3306
- GLPI_INSTALL_MODE=DOCKER
ports:
- "8080:80"
depends_on:
db:
condition: service_healthy

db:
image: mariadb:10.11
restart: "no"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: glpi
MYSQL_USER: glpi
MYSQL_PASSWORD: glpi
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 10s
interval: 10s
timeout: 5s
retries: 3

volumes:
glpi_data:
db_data:
45 changes: 45 additions & 0 deletions download_sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -e -u -o pipefail

# Check for dependencies
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required but not installed. Aborting."; exit 1; }
command -v tar >/dev/null 2>&1 || { echo >&2 "tar is required but not installed. Aborting."; exit 1; }

VERSION="${1:-latest}"
TARGET_DIR="glpi/sources"

echo "Cleaning target directory $TARGET_DIR..."
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"

if [ "$VERSION" = "latest" ]; then
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but not installed. Aborting."; exit 1; }

echo "Fetching info for latest version..."
# Get tag name from latest release
API_URL="https://api.github.com/repos/glpi-project/glpi/releases/latest"
TAG_NAME=$(curl -s "$API_URL" | jq -r .tag_name)

if [ "$TAG_NAME" = "null" ]; then
echo "Error: Could not determine latest version from GitHub API."
exit 1
fi
echo "Latest version is $TAG_NAME"
VERSION=$TAG_NAME
fi

# Construct download URL for source code tarball
# We use the archive url pattern: https://github.com/glpi-project/glpi/archive/refs/tags/{TAG}.tar.gz
URL="https://github.com/glpi-project/glpi/archive/refs/tags/${VERSION}.tar.gz"

echo "Downloading GLPI $VERSION sources from $URL..."
curl -L --output glpi-sources.tar.gz "$URL"

echo "Extracting to $TARGET_DIR..."
# Strip 1 component because github archives wrap in a folder like glpi-10.0.10/
tar --extract --ungzip --strip-components=1 --file glpi-sources.tar.gz --directory "$TARGET_DIR"

echo "Cleaning up..."
rm glpi-sources.tar.gz

echo "Success! Sources for $VERSION installed in $TARGET_DIR"