diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..54016c792 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,43 @@ +name: Build and Push Docker Image + +on: + push: + tags: + - '*' + +jobs: + build-and-push-docker-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: docker/standalone/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/bin/rebuild.sh b/bin/rebuild.sh deleted file mode 100644 index 7aba0c5cc..000000000 --- a/bin/rebuild.sh +++ /dev/null @@ -1,2 +0,0 @@ -docker-compose -f docker/docker-compose.yml down -docker-compose -f docker/docker-compose.yml build --no-cache diff --git a/bin/startdocker.sh b/bin/startdocker.sh deleted file mode 100644 index 57a6c5154..000000000 --- a/bin/startdocker.sh +++ /dev/null @@ -1,2 +0,0 @@ -docker-compose -f docker/docker-compose.yml down -docker-compose -f docker/docker-compose.yml up -d --force-recreate --remove-orphans diff --git a/bin/stopdocker.sh b/bin/stopdocker.sh deleted file mode 100644 index f0bed643b..000000000 --- a/bin/stopdocker.sh +++ /dev/null @@ -1 +0,0 @@ -docker-compose -f docker/docker-compose.yml down diff --git a/config/logging.php b/config/logging.php index 5aa1dbb78..5d4134ffa 100644 --- a/config/logging.php +++ b/config/logging.php @@ -61,6 +61,7 @@ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), + 'permission' => 0664, ], 'daily' => [ @@ -68,6 +69,7 @@ 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, + 'permission' => 0664, ], 'slack' => [ @@ -116,6 +118,7 @@ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), + 'permission' => 0664, ], ], diff --git a/docker/development/.gitignore b/docker/development/.gitignore new file mode 100755 index 000000000..aaec72ce4 --- /dev/null +++ b/docker/development/.gitignore @@ -0,0 +1,3 @@ +!.gitignore +mysql +nginx_config diff --git a/docker/development/README.md b/docker/development/README.md new file mode 100644 index 000000000..46f3f9c95 --- /dev/null +++ b/docker/development/README.md @@ -0,0 +1,23 @@ +# 🐳 Docker Development Environment + +This development environment utilizes standalone Docker with necessary tools pre-configured. + +## Included Services +- Redis +- MySQL +- Tools like phpMyAdmin + +## Not Included Services (for the moment) +- Pterodactyl +- Wings + +Feel free to modify the Docker Compose file to remove any services you already have. + +## Setting Up the Testing Environment + +1. **Manual Setup:** As mentioned in the standalone Docker guide, you will need to manually set up some components. +2. **Custom Configuration:** Modify the CtrlPanel Docker Compose configuration to use your current project as a base. If you point it to an empty folder, it will clone the repository, and you won't see your changes immediately. + +For detailed setup instructions, refer to the standalone Docker documentation. + +⚠ Caution: These instructions have not been finished. Therefore, there may be inaccuracies, instability, or non-functional aspects. Proceed with care. diff --git a/docker/docker-compose.yml b/docker/development/compose.yaml similarity index 51% rename from docker/docker-compose.yml rename to docker/development/compose.yaml index d41e258bc..1e8571a05 100644 --- a/docker/docker-compose.yml +++ b/docker/development/compose.yaml @@ -1,23 +1,19 @@ -version: '3' - -networks: - laravel: - services: - nginx: + # TODO: add wings and pterodactyl + ctrlpanel_development: build: - context: ../ - dockerfile: docker/nginx/Dockerfile - container_name: ctrlpanel_nginx + context: ../../ + dockerfile: ./docker/standalone/Dockerfile + container_name: ctrlpanel_development + restart: unless-stopped ports: - - 80:80 + - "80:80" + - "443:443" volumes: - - "../:/var/www/html" - depends_on: - - php - - mysql + - '../..:/var/www/html:rw' + - './nginx_config:/etc/nginx/conf.d/:rw' networks: - - laravel + - ctrlpanel mysql: image: mysql @@ -28,23 +24,13 @@ services: - "3306:3306" environment: MYSQL_DATABASE: ctrlpanel - MYSQL_USER: ctrlpanel + MYSQL_USER: ctrlpaneluser MYSQL_PASSWORD: root MYSQL_ROOT_PASSWORD: root volumes: - - "mysql:/var/lib/mysql:delegated" - networks: - - laravel - - php: - build: - context: ../ - dockerfile: docker/php/Dockerfile - container_name: ctrlpanel_php - volumes: - - "../:/var/www/html" + - "./mysql:/var/lib/mysql:delegated" networks: - - laravel + - ctrlpanel phpmyadmin: image: phpmyadmin/phpmyadmin @@ -59,7 +45,16 @@ services: - PMA_PASSWORD=root - PMA_ARBITRARY=1 networks: - - laravel + - ctrlpanel -volumes: - mysql: + redis: + image: redis + container_name: ctrlpanel_redis + restart: unless-stopped + ports: + - "6379:6379" + networks: + - ctrlpanel + +networks: + ctrlpanel: diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile deleted file mode 100644 index 51bf97ea1..000000000 --- a/docker/nginx/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM nginx:stable-alpine - -RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel - -ADD ./docker/nginx/nginx.conf /etc/nginx/ -ADD ./docker/nginx/default.conf /etc/nginx/conf.d/ - -RUN mkdir -p /var/www/html - -RUN chown laravel:laravel /var/www/html diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile deleted file mode 100644 index 4b8d91dd9..000000000 --- a/docker/php/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM php:8.1-fpm-buster -RUN apt-get update \ - && apt-get install -y build-essential zlib1g-dev default-mysql-client curl gnupg procps vim git unzip libzip-dev libpq-dev libicu-dev libonig-dev libpng-dev libjpeg-dev libfreetype6-dev - -RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath - -ADD ./docker/php/www.conf /usr/local/etc/php-fpm.d/ - -RUN mkdir -p /var/www/html - -RUN addgroup --gid 1000 laravel && adduser --ingroup laravel --uid 1000 --shell /bin/sh --disabled-password --gecos "" laravel -RUN chown laravel:laravel /var/www/html - -WORKDIR /var/www/html - -USER laravel - -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile new file mode 100644 index 000000000..a16bed8cb --- /dev/null +++ b/docker/standalone/Dockerfile @@ -0,0 +1,62 @@ +FROM php:8.1-fpm + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + nginx \ + nano \ + curl \ + git \ + libcurl4-openssl-dev \ + libicu-dev \ + libzip-dev \ + libpng-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN pecl install redis \ + && docker-php-ext-enable redis \ + && docker-php-ext-install -j$(nproc) \ + mysqli \ + pdo \ + pdo_mysql \ + intl \ + zip \ + gd \ + bcmath \ + && rm -rf /tmp/* /var/cache/* + +# Install Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Create directory for application +RUN mkdir -p /var/default /var/www/html + +# Create user and group for Laravel +RUN groupadd -g 1000 laravel \ + && useradd -u 1000 -g laravel -ms /bin/bash laravel \ + && chown -R laravel:laravel /var/default /var/www/html + +# Copy application files +COPY --chown=laravel:laravel . /var/default + +# Copy PHP-FPM configuration +COPY --chown=laravel:laravel ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ + +# Copy Nginx configuration +COPY --chown=laravel:laravel ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf +# Create directory for Nginx logs +RUN mkdir -p /var/log/nginx && chown -R laravel:laravel /var/log/nginx + +# Expose ports +EXPOSE 80 443 + +# Copy startup script +COPY --chown=laravel:laravel ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh +# Make startup script executable +RUN chmod +x /usr/local/bin/startup-script.sh + +# Set the working directory +WORKDIR /var/www/html + +# Start the startup script +CMD ["/usr/local/bin/startup-script.sh"] diff --git a/docker/standalone/README.md b/docker/standalone/README.md new file mode 100644 index 000000000..2efaf6bfd --- /dev/null +++ b/docker/standalone/README.md @@ -0,0 +1,34 @@ +# 🐳 Standalone Docker + +The CtrlPanel standalone Docker enables users to run CtrlPanel easily with just a few clicks. + +To run CtrlPanel standalone Docker, you need to have Docker installed on your machine. Some server operating systems like Unraid, TrueNAS, etc.. already have Docker installed, making it even easier to run CtrlPanel. +If you're using a different operating system, you can follow the official Docker installation guide [here](https://docs.docker.com/get-docker/). + +Once you have Docker installed, you can run CtrlPanel standalone Docker by executing the following command: + +Running as commandline command: + +```bash +docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html ghcr.io/ctrlpanel-gg/panel:latest +``` + +This command will run the latest CtrlPanel Docker image from GitHub Container Registry and run it. + +Recommended way via Docker Compose: + +1. Copy and configure your docker compose file to your needs `curl -L -o compose.yaml https://raw.githubusercontent.com/Ctrlpanel-gg/panel/blob/main/docker/standalone/compose.yaml`. +2. Create the env file in the same directory as the compose file `touch env_file`. +3. When installing you need to update the `env_file` file. Change those two variables to: `MEMCACHED_HOST=redis` and `REDIS_HOST=redis`, to use the Redis server which comes with the docker compose installation. + +The control panel will be available at http://localhost/install and will be a completely fresh installation. + +Note that while the container contains the full CtrlPanel installation, you will still need to perform the basic setup. You can find instructions for this [here](https://ctrlpanel.gg/docs/Installation/getting-started#basic-setup). + +## 🏗️ Migrating from a previous bare metal installation + +If you are migrating, from a previous bare metal installation, you can follow the instructions [here]() (Soon on documentation). + +## 🧰 Creating your own Docker image + +If you want to create your own Docker image, you can follow the instructions [here]() (Soon on documentation). diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml new file mode 100644 index 000000000..b2d3ce2f4 --- /dev/null +++ b/docker/standalone/compose.yaml @@ -0,0 +1,62 @@ +services: + ctrlpanel_standalone: + image: ghcr.io/ctrlpanel-gg/panel:latest + container_name: ctrlpanel_standalone + restart: unless-stopped + depends_on: + - redis + ports: + - "80:80" + - "443:443" + volumes: + - './logs:/var/www/html/storage/logs:w' + - './env_file:/var/www/html/.env' + - './website_files:/var/www/html:rw' # optionally remove this bind mount, it's not needed unless you want access to all project files, to modify the project with addons/plugins. + - './nginx_config:/etc/nginx/conf.d/:rw' # optionally remove this bind mount, it's not needed unless you want to modify the project with addons/plugins. (dangerous to edit) + networks: + - ctrlpanel + + mysql: + image: mysql + container_name: ctrlpanel_mysql + restart: unless-stopped + tty: true + ports: + - "3306:3306" + environment: + MYSQL_DATABASE: ctrlpanel + MYSQL_USER: ctrlpaneluser + MYSQL_PASSWORD: root # change it + MYSQL_ROOT_PASSWORD: root # change it + volumes: + - "./mysql:/var/lib/mysql:delegated" + networks: + - ctrlpanel + + phpmyadmin: + image: phpmyadmin/phpmyadmin + container_name: ctrlpanel_phpmyadmin + restart: unless-stopped + depends_on: + - mysql + ports: + - '8080:80' + environment: + - PMA_HOST=ctrlpanel_mysql + - PMA_USER=root # change it + - PMA_PASSWORD=root # change it + - PMA_ARBITRARY=1 + networks: + - ctrlpanel + + redis: + image: redis + container_name: ctrlpanel_redis + restart: unless-stopped + ports: + - "6379:6379" + networks: + - ctrlpanel + +networks: + ctrlpanel: diff --git a/docker/nginx/default.conf b/docker/standalone/nginx/default.conf similarity index 56% rename from docker/nginx/default.conf rename to docker/standalone/nginx/default.conf index 282633d76..2fe700465 100644 --- a/docker/nginx/default.conf +++ b/docker/standalone/nginx/default.conf @@ -1,20 +1,21 @@ server { listen 80; - index index.php index.html; server_name _; root /var/www/html/public; + index index.php index.html index.htm index.nginx-debian.html; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { - try_files $uri =404; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass php:9000; - fastcgi_index index.php; + include snippets/fastcgi-php.conf; + fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; + } + + location ~ /\.ht { + deny all; } } diff --git a/docker/nginx/nginx.conf b/docker/standalone/nginx/nginx.conf similarity index 100% rename from docker/nginx/nginx.conf rename to docker/standalone/nginx/nginx.conf diff --git a/docker/php/www.conf b/docker/standalone/php/www.conf similarity index 100% rename from docker/php/www.conf rename to docker/standalone/php/www.conf diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh new file mode 100644 index 000000000..bf11b5bff --- /dev/null +++ b/docker/standalone/scripts/startup.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Log directory +LOG_DIR="/var/www/html/storage/logs" + +echo "Starting script..." + +echo "Clearing log file..." +# clean all logs in log directory +if [ -n "$LOG_DIR" ]; then + rm -f "$LOG_DIR/startup-script.log" +fi + +# Check if log directory exists +if [ ! -d "$LOG_DIR" ]; then + echo "Warning: Log directory does not exist (maybe first install ?). Logging disabled until restart." + LOG_DIR="" +fi + +# Function to log messages +log_message() { + if [ -n "$LOG_DIR" ]; then + echo "$1" >> "$LOG_DIR/startup-script.log" + fi + echo "$1" +} + +# Check if public folder is exists. If not, copy project. +if [ ! -d "/var/www/html/public" ]; then + log_message "Warning: project folder is empty. Copying default files..." + # Copy everything from /var/default to /var/www/html + cp -nr /var/default/. /var/www/html # Use -n to avoid overwriting existing files + chown -R laravel:laravel /var/www/html/ + chmod -R 755 /var/www/html/ +fi + +# Copy .env file for it to be available when starting the Docker container (to be able to bind-mount it to the host, instead of the entire project folder). +cp -n /var/default/.env.example /var/www/html/.env # Use -n to avoid overwriting existing files + +# Check and copy default Nginx configuration if not exists +if [ ! -f "/etc/nginx/conf.d/default.conf" ]; then + log_message "Warning: Nginx configuration not found. Copying default configuration..." + cp -n /var/default/docker/standalone/nginx/default.conf /etc/nginx/conf.d/default.conf +fi + +# Check and execute composer install if composer.json is present and there's no vendor directory +if [ -f "/var/www/html/composer.json" ] && [ ! -d "/var/www/html/vendor" ]; then + log_message "Warning: Composer dependencies not found. Running composer install..." + cd /var/www/html || exit + composer install --no-dev --optimize-autoloader + cd - || exit +fi + +# Start the queue worker service +log_message "Starting the queue worker service..." +runuser -u laravel -- php /var/www/html/artisan queue:work --sleep=3 --tries=3 & + +# Start Nginx +log_message "Starting Nginx..." +service nginx start + +# Start PHP-FPM +log_message "Starting PHP-FPM..." +php-fpm -F diff --git a/themes/default/views/information/tos-content.blade.php b/themes/default/views/information/tos-content.blade.php index e9a42927f..cec69f4ad 100644 --- a/themes/default/views/information/tos-content.blade.php +++ b/themes/default/views/information/tos-content.blade.php @@ -18,7 +18,7 @@
  1. AGREEMENT TO TERMS
  2. -
  3. NTELLECTUAL PROPERTY RIGHTS
  4. +
  5. INTELLECTUAL PROPERTY RIGHTS
  6. USER REPRESENTATIONS
  7. USER REGISTRATION
  8. PRODUCTS