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
80 changes: 80 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
FROM php:8.4-fpm

# Set working directory
WORKDIR /var/www/html

# Install system dependencies and enable PHP extensions
RUN apt-get update && apt-get install -y \
git \
unzip \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libzip-dev \
libicu-dev \
libonig-dev \
libxml2-dev \
libcurl4-openssl-dev \
libssl-dev \
wget \
supervisor \
default-mysql-client \
sudo \
nginx \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
gd \
mysqli \
pdo_mysql \
zip \
intl \
mbstring \
xml \
curl \
opcache \
sockets

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Configure PHP
COPY .devcontainer/php.ini /usr/local/etc/php/conf.d/php.ini

# Configure Nginx
COPY .devcontainer/nginx.conf /etc/nginx/sites-available/default

# Set proper permissions
RUN chown -R www-data:www-data /var/www/html

# Install xdebug for debugging
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

# Development tools
RUN apt-get install -y \
vim \
nano \
iputils-ping \
procps \
less \
htop \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Create developer user - simplified approach
RUN useradd -m -s /bin/bash developer && \
echo "developer:developer" | chpasswd && \
adduser developer sudo && \
echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
usermod -aG www-data developer && \
chown -R developer:developer /var/www/html

# Expose port 80
EXPOSE 80

# Create start script
COPY .devcontainer/start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh

# Start Nginx and PHP-FPM
CMD ["/usr/local/bin/start.sh"]
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "osTicket Development",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/var/www/html",
"forwardPorts": [8080, 3306],
"remoteUser": "developer",
"customizations": {
"vscode": {
"extensions": [
"xdebug.php-debug",
"bmewburn.vscode-intelephense-client",
"mrmlnc.vscode-apache",
"mikestead.dotenv",
"redhat.vscode-yaml",
"editorconfig.editorconfig",
"formulahendry.auto-close-tag",
"mechatroner.rainbow-csv",
"ms-azuretools.vscode-docker",
"neilbrayfield.php-docblocker",
"mehedidracula.php-namespace-resolver",
"recca0120.vscode-phpunit",
"junstyle.php-cs-fixer",
"felixfbecker.php-intellisense",
"swordev.phpstan",
"mtxr.sqltools",
"mtxr.sqltools-driver-mysql"
],
"settings": {
"php.validate.executablePath": "/usr/local/bin/php",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"files.associations": {
"*.inc.php": "php",
"*.phtml": "php"
},
"php.suggest.basic": true
}
}
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
}
}
54 changes: 54 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: "3.8"

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ..:/var/www/html
- ./setup-script.sh:/usr/local/bin/setup-script.sh
- ./start.sh:/usr/local/bin/start.sh
- ./nginx.conf:/etc/nginx/sites-available/default
ports:
- 8080:80
environment:
- PHP_MAX_EXECUTION_TIME=300
- PHP_MEMORY_LIMIT=256M
- PHP_UPLOAD_MAX_FILESIZE=64M
- PHP_POST_MAX_SIZE=64M
- MYSQL_HOST=db
- MYSQL_PORT=3306
- MYSQL_DATABASE=osticket
- MYSQL_USER=osticket
- MYSQL_PASSWORD=osticket
depends_on:
- db
restart: unless-stopped
networks:
- osticket-network
command: >
bash -c "/usr/local/bin/setup-script.sh && /usr/local/bin/start.sh"

db:
image: mysql:8.0
restart: unless-stopped
volumes:
- osticket-mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: osticket
MYSQL_USER: osticket
MYSQL_PASSWORD: osticket
ports:
- 3306:3306
networks:
- osticket-network
command: --default-authentication-plugin=mysql_native_password

networks:
osticket-network:
driver: bridge

volumes:
osticket-mysql-data:
76 changes: 76 additions & 0 deletions .devcontainer/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html;

client_max_body_size 64M;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location ~ /include {
deny all;
return 403;
}

if ($request_uri ~ "^/api(/[^\?]+)") {
set $path_info $1;
}

location /api {
try_files $uri $uri/ /api/http.php?$query_string;
}

if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
set $path_info $1;
}

location ~ ^/scp/ajax.php/.*$ {
try_files $uri $uri/ /scp/ajax.php?$query_string;
}

if ($request_uri ~ "^/ajax.php(/[^\?]+)") {
set $path_info $1;
}

location ~ ^/ajax.php/.*$ {
try_files $uri $uri/ /ajax.php?$query_string;
}

location / {
try_files $uri $uri/ index.php;
}

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { access_log off; log_not_found off; }

# Deny .htaccess file access
location ~ /\.ht {
deny all;
}

location ~ \.php$ {
try_files $uri = 404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param LARA_ENV local; # Environment variable for Laravel
fastcgi_param PATH_INFO $path_info;
fastcgi_pass 127.0.0.1:9000;
}


# location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_intercept_errors off;
# fastcgi_buffer_size 16k;
# fastcgi_buffers 4 16k;
# fastcgi_param HTTPS off;
# }

}
17 changes: 17 additions & 0 deletions .devcontainer/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; PHP Development Configuration
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
date.timezone = UTC
display_errors = On
error_reporting = E_ALL
log_errors = On

; XDebug configuration
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
xdebug.log = /tmp/xdebug.log
110 changes: 110 additions & 0 deletions .devcontainer/setup-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash
set -e

export MYSQL_HOST=${MYSQL_HOST}
export MYSQL_PORT=${MYSQL_PORT}
export MYSQL_DATABASE=${MYSQL_DATABASE}
export MYSQL_USER=${MYSQL_USER}
export MYSQL_PASSWORD=${MYSQL_PASSWORD}

# Wait for MySQL to be ready
echo "Waiting for MySQL [${MYSQL_HOST}] to be ready..."
until mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e "SELECT 1" >/dev/null 2>&1; do
echo "MySQL [${MYSQL_HOST}] is unavailable - sleeping"
sleep 2
done
echo "MySQL is up - continuing"

# Check if osTicket is already installed
DB_INITIALIZED=$(mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e "SHOW TABLES FROM ${MYSQL_DATABASE}" 2>/dev/null | wc -l)
CONFIG_EXISTS=$([ -f "/var/www/html/include/ost-config.php" ] && echo "yes" || echo "no")

# Prepare setup directory if it doesn't exist
if [ ! -d "/var/www/html/setup_hidden" ] && [ -d "/var/www/html/setup" ]; then
echo "Creating setup_hidden directory"
cp -r /var/www/html/setup /var/www/html/setup_hidden
# chmod -R 755 /var/www/html/setup_hidden
fi

# Use install.php script to initialize osTicket if needed
if [ "$DB_INITIALIZED" -le "1" ] || [ "$CONFIG_EXISTS" = "no" ]; then
echo "Initializing osTicket using install.php script..."

# Create a modified version of the sample config file in a temporary location
if [ ! -d "/var/www/html/include" ]; then
mkdir -p /var/www/html/include
fi

# Make sure sample config exists
if [ ! -f "/var/www/html/include/ost-sampleconfig.php" ]; then
echo "Error: Sample config file not found!"
exit 1
fi

# Copy sample config for the installer to use
cp /var/www/html/include/ost-sampleconfig.php /tmp/ost-config-temp.php
chmod 0666 /tmp/ost-config-temp.php

# Add SESSION_TTL constant with shorter expiration time (e.g., 1800 seconds = 30 minutes)
# This needs to match your OAuth2 provider's session timeout
# echo "# Adding custom SESSION_TTL setting to config" >> /tmp/ost-config-temp.php
# echo "define('SESSION_TTL', 1800);" >> /tmp/ost-config-temp.php

# Set up environment variables for the installer
export INSTALL_NAME="osTicket Support"
export INSTALL_EMAIL="helpdesk@example.com"
export INSTALL_URL="http://localhost:8080/"
export ADMIN_FIRSTNAME="Admin"
export ADMIN_LASTNAME="User"
export ADMIN_EMAIL="admin@example.com"
export ADMIN_USERNAME="ostadmin"
export ADMIN_PASSWORD="Admin1"
export MYSQL_PREFIX="ost_"
export MYSQL_HOST=${MYSQL_HOST}
export MYSQL_PORT=${MYSQL_PORT}
export MYSQL_DATABASE=${MYSQL_DATABASE}
export MYSQL_USER=${MYSQL_USER}
export MYSQL_PASSWORD=${MYSQL_PASSWORD}
export INSTALL_CONFIG="/tmp/ost-config-temp.php"

# Check if the install.php file exists in the correct location
if [ -f "/var/www/html/docker/files/data/bin/install.php" ]; then
echo "Found install.php at /var/www/html/docker/files/data/bin/install.php"
php /var/www/html/docker/files/data/bin/install.php
else
echo "Warning: Could not find install.php in the expected location."
echo "Falling back to setup methods..."

# Use setup/install.php instead since we're building from source
cd /var/www/html/setup
php -f install.php
fi

# Set proper permissions for config file
if [ -f "/var/www/html/include/ost-config.php" ]; then
chmod 0644 /var/www/html/include/ost-config.php
echo "Installation completed successfully!"
else
echo "Installation might have failed. Config file not found."
fi

# Clean up
rm -f /tmp/ost-config-temp.php
else
echo "osTicket is already installed."
fi

# Set proper permissions for development
# chmod -R 775 /var/www/html/include

# Set proper permission for attachments directory
if [ ! -d "/var/www/html/uploads/tickets" ]; then
mkdir -p /var/www/html/uploads/tickets
fi

chmod -R 775 /var/www/html/uploads

echo "osTicket development environment is ready!"
echo "Admin login: ${ADMIN_USERNAME} / ${ADMIN_PASSWORD}"
echo "Access the helpdesk at: http://localhost:8080"
echo "Access the admin panel at: http://localhost:8080/scp"
Loading