From 312e53a01e1e97e0f928a0eb30e43877cc703649 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 30 Apr 2024 14:07:42 +0200 Subject: [PATCH 01/73] UPDATE: moved the developement docker into a developement folder --- docker/{ => development}/docker-compose.yml | 12 ++++++------ docker/{ => development}/nginx/Dockerfile | 4 ++-- docker/{ => development}/nginx/default.conf | 0 docker/{ => development}/nginx/nginx.conf | 0 docker/{ => development}/php/Dockerfile | 2 +- docker/{ => development}/php/www.conf | 0 6 files changed, 9 insertions(+), 9 deletions(-) rename docker/{ => development}/docker-compose.yml (82%) rename docker/{ => development}/nginx/Dockerfile (60%) rename docker/{ => development}/nginx/default.conf (100%) rename docker/{ => development}/nginx/nginx.conf (100%) rename docker/{ => development}/php/Dockerfile (90%) rename docker/{ => development}/php/www.conf (100%) diff --git a/docker/docker-compose.yml b/docker/development/docker-compose.yml similarity index 82% rename from docker/docker-compose.yml rename to docker/development/docker-compose.yml index 56c9e24de..16c9bf94f 100644 --- a/docker/docker-compose.yml +++ b/docker/development/docker-compose.yml @@ -6,13 +6,13 @@ networks: services: nginx: build: - context: ../ - dockerfile: docker/nginx/Dockerfile + context: ../../ + dockerfile: docker/development/nginx/Dockerfile container_name: controlpanel_nginx ports: - 80:80 volumes: - - "../:/var/www/html" + - "../../:/var/www/html" depends_on: - php - mysql @@ -38,11 +38,11 @@ services: php: build: - context: ../ - dockerfile: docker/php/Dockerfile + context: ../../ + dockerfile: docker/development/php/Dockerfile container_name: controlpanel_php volumes: - - "../:/var/www/html" + - "../../:/var/www/html" networks: - laravel diff --git a/docker/nginx/Dockerfile b/docker/development/nginx/Dockerfile similarity index 60% rename from docker/nginx/Dockerfile rename to docker/development/nginx/Dockerfile index 51bf97ea1..deca865f1 100644 --- a/docker/nginx/Dockerfile +++ b/docker/development/nginx/Dockerfile @@ -2,8 +2,8 @@ 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/ +ADD ./docker/development/nginx/nginx.conf /etc/nginx/ +ADD ./docker/development/nginx/default.conf /etc/nginx/conf.d/ RUN mkdir -p /var/www/html diff --git a/docker/nginx/default.conf b/docker/development/nginx/default.conf similarity index 100% rename from docker/nginx/default.conf rename to docker/development/nginx/default.conf diff --git a/docker/nginx/nginx.conf b/docker/development/nginx/nginx.conf similarity index 100% rename from docker/nginx/nginx.conf rename to docker/development/nginx/nginx.conf diff --git a/docker/php/Dockerfile b/docker/development/php/Dockerfile similarity index 90% rename from docker/php/Dockerfile rename to docker/development/php/Dockerfile index 4b8d91dd9..3ec761ae7 100644 --- a/docker/php/Dockerfile +++ b/docker/development/php/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update \ RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath -ADD ./docker/php/www.conf /usr/local/etc/php-fpm.d/ +ADD ./docker/development/php/www.conf /usr/local/etc/php-fpm.d/ RUN mkdir -p /var/www/html diff --git a/docker/php/www.conf b/docker/development/php/www.conf similarity index 100% rename from docker/php/www.conf rename to docker/development/php/www.conf From 31c79cbc99223ce73700e5786a7fd6cd49fc9a12 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 30 Apr 2024 14:07:53 +0200 Subject: [PATCH 02/73] ADD: added a standalone docker --- docker/standalone/Dockerfile | 45 +++ docker/standalone/docker-compose.yml | 18 ++ docker/standalone/nginx/default.conf | 21 ++ docker/standalone/nginx/nginx.conf | 29 ++ docker/standalone/php/www.conf | 439 +++++++++++++++++++++++++++ 5 files changed, 552 insertions(+) create mode 100644 docker/standalone/Dockerfile create mode 100644 docker/standalone/docker-compose.yml create mode 100644 docker/standalone/nginx/default.conf create mode 100644 docker/standalone/nginx/nginx.conf create mode 100644 docker/standalone/php/www.conf diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile new file mode 100644 index 000000000..a0efd6ed3 --- /dev/null +++ b/docker/standalone/Dockerfile @@ -0,0 +1,45 @@ +FROM php:8.1-fpm + +# Install Nginx and other dependencies +RUN apt-get update && apt-get install -y \ + nginx \ + curl \ + libcurl4-openssl-dev \ + libicu-dev \ + libzip-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip + +# Copy the custom PHP-FPM configuration +ADD ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ + +# Create directory for application and set ownership +RUN mkdir -p /var/www/html && \ + groupadd -g 1000 laravel && \ + useradd -u 1000 -g laravel -ms /bin/bash laravel && \ + chown laravel:laravel /var/www/html + +# Set the working directory +WORKDIR /var/www/html + +# Copy Composer binary from Composer image +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Configure Nginx +COPY ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf +COPY ./docker/standalone/nginx/default.conf /etc/nginx/conf.d/default.conf + +# Create directory for Nginx logs and set ownership +RUN mkdir -p /var/log/nginx && \ + chown -R laravel:laravel /var/log/nginx + +# Expose ports +EXPOSE 80 + +# Run composer install if composer.json is present +RUN if [ -f composer.json ]; then composer install --no-dev --optimize-autoloader; fi + +# Start both PHP-FPM and Nginx +CMD ["sh", "-c", "service nginx start && php-fpm -F"] diff --git a/docker/standalone/docker-compose.yml b/docker/standalone/docker-compose.yml new file mode 100644 index 000000000..a55c85d86 --- /dev/null +++ b/docker/standalone/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' + +services: + web: + build: + context: ../../ + dockerfile: ./docker/standalone/Dockerfile + container_name: controlpanel_web + ports: + - "80:80" + volumes: + - "../../:/var/www/html:delegated" + environment: + - DB_HOST=10.0.0.16 + - DB_PORT=3306 + - DB_DATABASE=controlpanel + - DB_USERNAME=controlpaneluser + - DB_PASSWORD=pass diff --git a/docker/standalone/nginx/default.conf b/docker/standalone/nginx/default.conf new file mode 100644 index 000000000..2fe700465 --- /dev/null +++ b/docker/standalone/nginx/default.conf @@ -0,0 +1,21 @@ +server { + listen 80; + 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$ { + include snippets/fastcgi-php.conf; + fastcgi_pass 127.0.0.1:9000; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ /\.ht { + deny all; + } +} diff --git a/docker/standalone/nginx/nginx.conf b/docker/standalone/nginx/nginx.conf new file mode 100644 index 000000000..060e50253 --- /dev/null +++ b/docker/standalone/nginx/nginx.conf @@ -0,0 +1,29 @@ +user laravel; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/docker/standalone/php/www.conf b/docker/standalone/php/www.conf new file mode 100644 index 000000000..eb028e111 --- /dev/null +++ b/docker/standalone/php/www.conf @@ -0,0 +1,439 @@ +; Start a new pool named 'www'. +; the variable $pool can be used in any directive and will be replaced by the +; pool name ('www' here) +[www] + +; Per pool prefix +; It only applies on the following directives: +; - 'access.log' +; - 'slowlog' +; - 'listen' (unixsocket) +; - 'chroot' +; - 'chdir' +; - 'php_values' +; - 'php_admin_values' +; When not set, the global prefix (or NONE) applies instead. +; Note: This directive can also be relative to the global prefix. +; Default Value: none +;prefix = /path/to/pools/$pool + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = laravel +group = laravel + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on +; a specific port; +; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = 127.0.0.1:9000 + +; Set listen(2) backlog. +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. The owner +; and group can be specified either by name or by their numeric IDs. +; Default Values: user and group are set as the running user +; mode is set to 0660 +;listen.owner = www-data +;listen.group = www-data +;listen.mode = 0660 +; When POSIX Access Control Lists are supported you can set them using +; these options, value is a comma separated list of user/group names. +; When set, listen.owner and listen.group are ignored +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. +; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original +; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address +; must be separated by a comma. If this value is left blank, connections will be +; accepted from any ip address. +; Default Value: any +;listen.allowed_clients = 127.0.0.1 + +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 + +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = dynamic + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = 5 + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: (min_spare_servers + max_spare_servers) / 2 +pm.start_servers = 2 + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = 1 + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = 3 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +;pm.max_requests = 500 + +; The URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in ยตs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: /usr/local/share/php/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +;pm.status_path = /status + +; The ping URI to call the monitoring page of FPM. If this value is not set, no +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +;ping.path = /ping + +; This directive may be used to customize the response of a ping request. The +; response is formatted as text/plain with a 200 response code. +; Default Value: pong +;ping.response = pong + +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow + +; The timeout for serving a single request after which a PHP backtrace will be +; dumped to the 'slowlog' file. A value of '0s' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_slowlog_timeout = 0 + +; Depth of slow log stack trace. +; Default Value: 20 +;request_slowlog_trace_depth = 20 + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_terminate_timeout = 0 + +; The timeout set by 'request_terminate_timeout' ini option is not engaged after +; application calls 'fastcgi_finish_request' or when application has finished and +; shutdown functions are being called (registered via register_shutdown_function). +; This option will enable timeout limit to be applied unconditionally +; even in such cases. +; Default Value: no +;request_terminate_timeout_track_finished = no + +; Set open file descriptor rlimit. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Chroot to this directory at the start. This value must be defined as an +; absolute path. When this value is not set, chroot is not used. +; Note: you can prefix with '$prefix' to chroot to the pool prefix or one +; of its subdirectories. If the pool prefix is not set, the global prefix +; will be used instead. +; Note: chrooting is a great security feature and should be used whenever +; possible. However, all PHP paths will be relative to the chroot +; (error_log, sessions.save_path, ...). +; Default Value: not set +;chroot = + +; Chdir to this directory at the start. +; Note: relative path can be used. +; Default Value: current directory or / when chroot +;chdir = /var/www + +; Redirect worker stdout and stderr into main error log. If not set, stdout and +; stderr will be redirected to /dev/null according to FastCGI specs. +; Note: on highloaded environement, this can cause some delay in the page +; process time (several ms). +; Default Value: no +;catch_workers_output = yes + +; Decorate worker output with prefix and suffix containing information about +; the child that writes to the log and if stdout or stderr is used as well as +; log level and time. This options is used only if catch_workers_output is yes. +; Settings to "no" will output data as written to the stdout or stderr. +; Default value: yes +;decorate_workers_output = no + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + +; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from +; the current environment. +; Default Value: clean env +;env[HOSTNAME] = $HOSTNAME +;env[PATH] = /usr/local/bin:/usr/bin:/bin +;env[TMP] = /tmp +;env[TMPDIR] = /tmp +;env[TEMP] = /tmp + +; Additional php.ini defines, specific to this pool of workers. These settings +; overwrite the values previously defined in the php.ini. The directives are the +; same as the PHP SAPI: +; php_value/php_flag - you can set classic ini defines which can +; be overwritten from PHP call 'ini_set'. +; php_admin_value/php_admin_flag - these directives won't be overwritten by +; PHP call 'ini_set' +; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. + +; Defining 'extension' will load the corresponding shared extension from +; extension_dir. Defining 'disable_functions' or 'disable_classes' will not +; overwrite previously defined php.ini values, but will append the new value +; instead. + +; Note: path INI options can be relative and will be expanded with the prefix +; (pool, global or /usr/local) + +; Default Value: nothing is defined by default except the values in php.ini and +; specified at startup with the -d argument +;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com +;php_flag[display_errors] = off +;php_admin_value[error_log] = /var/log/fpm-php.www.log +;php_admin_flag[log_errors] = on +;php_admin_value[memory_limit] = 32M From d10c7ac4aaabbb6c70e945a28629aa423e2425b7 Mon Sep 17 00:00:00 2001 From: S0ly Date: Fri, 3 May 2024 13:25:58 +0200 Subject: [PATCH 03/73] REMOVED: binary for docker compose execution that where not used anymore --- bin/rebuild.sh | 2 -- bin/startdocker.sh | 2 -- bin/stopdocker.sh | 1 - 3 files changed, 5 deletions(-) delete mode 100644 bin/rebuild.sh delete mode 100644 bin/startdocker.sh delete mode 100644 bin/stopdocker.sh 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 From e3403963d3509f6f639da5323e24e8e5c2a04387 Mon Sep 17 00:00:00 2001 From: S0ly Date: Fri, 3 May 2024 13:28:03 +0200 Subject: [PATCH 04/73] UPDATE: moved the building.md to the developement docker --- BUILDING.md => docker/development/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename BUILDING.md => docker/development/README.md (100%) diff --git a/BUILDING.md b/docker/development/README.md similarity index 100% rename from BUILDING.md rename to docker/development/README.md From 96041d1eac02f85847156b50c04412adc50495c7 Mon Sep 17 00:00:00 2001 From: S0ly Date: Fri, 3 May 2024 13:28:15 +0200 Subject: [PATCH 05/73] ADD: empty readme for the standalone docker --- docker/standalone/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docker/standalone/README.md diff --git a/docker/standalone/README.md b/docker/standalone/README.md new file mode 100644 index 000000000..e69de29bb From b52aeb229616e689438fe50b4df1adab4347c7aa Mon Sep 17 00:00:00 2001 From: S0ly Date: Sun, 5 May 2024 18:22:28 +0200 Subject: [PATCH 06/73] UPDATE: made a working standalone docker whit a startup script for easy deployment and managability --- docker/standalone/Dockerfile | 20 +++++++++++--------- docker/standalone/docker-compose.yml | 13 ++++--------- docker/standalone/scripts/startup.sh | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 docker/standalone/scripts/startup.sh diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index a0efd6ed3..aafd194ad 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -16,20 +16,19 @@ RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip ADD ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ # Create directory for application and set ownership -RUN mkdir -p /var/www/html && \ +RUN mkdir -p /var/default && \ groupadd -g 1000 laravel && \ useradd -u 1000 -g laravel -ms /bin/bash laravel && \ - chown laravel:laravel /var/www/html + chown laravel:laravel /var/default -# Set the working directory -WORKDIR /var/www/html +# Copy application files into the container +COPY . /var/default # Copy Composer binary from Composer image COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Configure Nginx COPY ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf -COPY ./docker/standalone/nginx/default.conf /etc/nginx/conf.d/default.conf # Create directory for Nginx logs and set ownership RUN mkdir -p /var/log/nginx && \ @@ -38,8 +37,11 @@ RUN mkdir -p /var/log/nginx && \ # Expose ports EXPOSE 80 -# Run composer install if composer.json is present -RUN if [ -f composer.json ]; then composer install --no-dev --optimize-autoloader; fi +# Copy startup script +COPY ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh -# Start both PHP-FPM and Nginx -CMD ["sh", "-c", "service nginx start && php-fpm -F"] +# Make startup script executable +RUN chmod +x /usr/local/bin/startup-script.sh + +# Start the startup script +CMD ["/usr/local/bin/startup-script.sh"] diff --git a/docker/standalone/docker-compose.yml b/docker/standalone/docker-compose.yml index a55c85d86..ed5dc8478 100644 --- a/docker/standalone/docker-compose.yml +++ b/docker/standalone/docker-compose.yml @@ -1,18 +1,13 @@ version: '3' services: - web: + controlpanel_web: build: context: ../../ dockerfile: ./docker/standalone/Dockerfile - container_name: controlpanel_web + container_name: controlpanel ports: - "80:80" volumes: - - "../../:/var/www/html:delegated" - environment: - - DB_HOST=10.0.0.16 - - DB_PORT=3306 - - DB_DATABASE=controlpanel - - DB_USERNAME=controlpaneluser - - DB_PASSWORD=pass + - '/mnt/user/appdata/ctrlpanel/www/:/var/www/html:rw' + - '/mnt/user/appdata/ctrlpanel/nginx/:/etc/nginx/conf.d/:rw' diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh new file mode 100644 index 000000000..942e9f8e1 --- /dev/null +++ b/docker/standalone/scripts/startup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Check if /var/www/html is empty or .env file doesn't exist +if [ -z "$(ls -A /var/www/html)" ] || [ ! -f "/var/www/html/.env" ]; then + # Copy everything from /var/default to /var/www/html + cp -nr /var/default/. /var/www/html # Use -n to avoid overwriting existing files + + # Copy default Nginx configuration + cp -n /var/default/docker/standalone/nginx/default.conf /etc/nginx/conf.d/default.conf + + # 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 + cd /var/www/html + composer install --no-dev --optimize-autoloader + cd - + fi +fi + +# Start Nginx +service nginx start + +# Start PHP-FPM +php-fpm -F From 1403985b24201d795a9199f3e0f7da26d73b3c85 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 7 May 2024 13:52:51 +0200 Subject: [PATCH 07/73] UPDATE: added more php dependency to the standalone dockerfile --- docker/standalone/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index aafd194ad..62957baf0 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -7,10 +7,11 @@ RUN apt-get update && apt-get install -y \ libcurl4-openssl-dev \ libicu-dev \ libzip-dev \ + libpng-dev \ && rm -rf /var/lib/apt/lists/* # Install PHP extensions -RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip +RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath # Copy the custom PHP-FPM configuration ADD ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ From 469a814a6bb3898849ff55da2557e072237676cb Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 7 May 2024 13:53:19 +0200 Subject: [PATCH 08/73] UPDATE: made a better standalone docker compose --- docker/standalone/docker-compose.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docker/standalone/docker-compose.yml b/docker/standalone/docker-compose.yml index ed5dc8478..cd980a2af 100644 --- a/docker/standalone/docker-compose.yml +++ b/docker/standalone/docker-compose.yml @@ -1,13 +1,15 @@ version: '3' services: - controlpanel_web: + controlpanel_standalone: build: context: ../../ dockerfile: ./docker/standalone/Dockerfile - container_name: controlpanel + container_name: controlpanel_standalone + restart: on-failure ports: - "80:80" + - "443:443" volumes: - - '/mnt/user/appdata/ctrlpanel/www/:/var/www/html:rw' - - '/mnt/user/appdata/ctrlpanel/nginx/:/etc/nginx/conf.d/:rw' + - './website_files:/var/www/html:rw' # change it + - './nginx_config:/etc/nginx/conf.d/:rw' # change it From cb2ea111e720badbe13626bf3972b8683716674a Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 7 May 2024 13:53:37 +0200 Subject: [PATCH 09/73] UPDATE: made a better readme documentation for the standalone docker --- docker/standalone/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docker/standalone/README.md b/docker/standalone/README.md index e69de29bb..0b7fa291b 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -0,0 +1,23 @@ +## ๐Ÿณ 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: + +```bash +docker run ... +``` + +This command will pull the latest CtrlPanel Docker image from Docker Hub and run it. + +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). + +## ๐Ÿ—๏ธ Advanced Docker + +If you are migrating, or want to create your own Docker image, you can follow the instructions [here](). From 5faea04fba77626e961d6b11a78ec0f7a638d367 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 7 May 2024 14:21:10 +0200 Subject: [PATCH 10/73] UPDATE: updated the standalone docker configuration --- docker/standalone/README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docker/standalone/README.md b/docker/standalone/README.md index 0b7fa291b..992b80c82 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -1,23 +1,26 @@ -## ๐Ÿณ Standalone Docker +# ๐Ÿณ 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: ```bash -docker run ... +docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html -v /path/to/nginx_config:/etc/nginx/conf.d/ ctrlpanel/ctrlpanel ``` -This command will pull the latest CtrlPanel Docker image from Docker Hub and run it. +This command will run the latest CtrlPanel Docker image from Docker Hub and run it. 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). -## ๐Ÿ—๏ธ Advanced Docker +## ๐Ÿ—๏ธ 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 are migrating, or want to create your own Docker image, you can follow the instructions [here](). +If you want to create your own Docker image, you can follow the instructions [here]() (Soon on documentation). From 27cad9173eb351efe3ebd39d27bc2b8522aaa2fd Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 7 May 2024 14:34:19 +0200 Subject: [PATCH 11/73] FIX: standalone dockerfile now expose port 443 --- docker/standalone/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 62957baf0..d59ca6947 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -37,6 +37,7 @@ RUN mkdir -p /var/log/nginx && \ # Expose ports EXPOSE 80 +EXPOSE 443 # Copy startup script COPY ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh From 84417a9f6119f8017c04a2d1d07336a1248a29e7 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 7 May 2024 23:36:45 +0200 Subject: [PATCH 12/73] UPDATE: added redis php extention to standalone docker --- docker/standalone/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index d59ca6947..5c4a0c277 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -10,8 +10,9 @@ RUN apt-get update && apt-get install -y \ libpng-dev \ && rm -rf /var/lib/apt/lists/* -# Install PHP extensions -RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath +# Install PHP extensions including Redis +RUN pecl install redis && docker-php-ext-enable redis \ + && docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath # Copy the custom PHP-FPM configuration ADD ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ From 7d191efa1b2b5d225aad69e39de05449dd70098c Mon Sep 17 00:00:00 2001 From: S0ly Date: Fri, 10 May 2024 18:36:35 +0200 Subject: [PATCH 13/73] ADD: some permission to files --- docker/standalone/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 5c4a0c277..2477e2337 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -36,6 +36,9 @@ COPY ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf RUN mkdir -p /var/log/nginx && \ chown -R laravel:laravel /var/log/nginx +# Set permissions for Laravel directories +RUN chown -R www-data:www-data /var/default/storage /var/default/bootstrap/cache + # Expose ports EXPOSE 80 EXPOSE 443 From a7e5ab29bdc5e340d55e9decd4b4afc1c31e97e9 Mon Sep 17 00:00:00 2001 From: S0ly Date: Fri, 10 May 2024 18:37:01 +0200 Subject: [PATCH 14/73] ADD: standalone docker Queue Worker --- docker/standalone/scripts/startup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 942e9f8e1..1c0de62ca 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -16,6 +16,9 @@ if [ -z "$(ls -A /var/www/html)" ] || [ ! -f "/var/www/html/.env" ]; then fi fi +# Start the queue worker service +php /var/www/html/artisan queue:work --sleep=3 --tries=3 & + # Start Nginx service nginx start From 0683e2d62bc9db5c7204ca31d30e105b7b2eb365 Mon Sep 17 00:00:00 2001 From: S0ly Date: Mon, 13 May 2024 10:29:24 +0200 Subject: [PATCH 15/73] ADD: nano to the standalone docker --- docker/standalone/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 2477e2337..f0bf06272 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -3,6 +3,7 @@ FROM php:8.1-fpm # Install Nginx and other dependencies RUN apt-get update && apt-get install -y \ nginx \ + nano \ curl \ libcurl4-openssl-dev \ libicu-dev \ From 26a279fcb815e2d4b31abf20ddbb0566d1ccc494 Mon Sep 17 00:00:00 2001 From: S0ly Date: Mon, 13 May 2024 10:31:26 +0200 Subject: [PATCH 16/73] FIX: tried to fix the standalone docker permissions --- docker/standalone/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index f0bf06272..bed185d42 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -37,8 +37,8 @@ COPY ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf RUN mkdir -p /var/log/nginx && \ chown -R laravel:laravel /var/log/nginx -# Set permissions for Laravel directories -RUN chown -R www-data:www-data /var/default/storage /var/default/bootstrap/cache +# Set permissions (i don't know why but this is necessary, otherwise the panel won't work properly) +RUN chown -R 777 /var/default/ # Expose ports EXPOSE 80 From 00397c1dc8eb8d959cf1b9c64fa18c8f6af644a7 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 14 May 2024 14:47:27 +0200 Subject: [PATCH 17/73] FIX: logging config permissions --- config/logging.php | 3 +++ 1 file changed, 3 insertions(+) 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, ], ], From e3957bc1924ee9eca685dba502e7b24e3dd9fa5d Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 14 May 2024 14:52:37 +0200 Subject: [PATCH 18/73] UPDATE: made a lot of change to the standalone dockerfile and script --- docker/standalone/Dockerfile | 66 ++++++++++++++++------------ docker/standalone/scripts/startup.sh | 55 ++++++++++++++++++----- 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index bed185d42..a16bed8cb 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -1,54 +1,62 @@ FROM php:8.1-fpm -# Install Nginx and other dependencies -RUN apt-get update && apt-get install -y \ +# 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 including Redis -RUN pecl install redis && docker-php-ext-enable redis \ - && docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath - -# Copy the custom PHP-FPM configuration -ADD ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ - -# Create directory for application and set ownership -RUN mkdir -p /var/default && \ - groupadd -g 1000 laravel && \ - useradd -u 1000 -g laravel -ms /bin/bash laravel && \ - chown laravel:laravel /var/default +# 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 -# Copy application files into the container -COPY . /var/default +# Create directory for application +RUN mkdir -p /var/default /var/www/html -# Copy Composer binary from Composer image -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +# 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 -# Configure Nginx -COPY ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf +# Copy application files +COPY --chown=laravel:laravel . /var/default -# Create directory for Nginx logs and set ownership -RUN mkdir -p /var/log/nginx && \ - chown -R laravel:laravel /var/log/nginx +# Copy PHP-FPM configuration +COPY --chown=laravel:laravel ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/ -# Set permissions (i don't know why but this is necessary, otherwise the panel won't work properly) -RUN chown -R 777 /var/default/ +# 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 -EXPOSE 443 +EXPOSE 80 443 # Copy startup script -COPY ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh - +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/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 1c0de62ca..5f36512d9 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -1,26 +1,61 @@ #!/bin/bash -# Check if /var/www/html is empty or .env file doesn't exist -if [ -z "$(ls -A /var/www/html)" ] || [ ! -f "/var/www/html/.env" ]; then +# 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 project folder is empty. +if [ -z "$(ls -A /var/www/html)" ]; 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 default Nginx configuration +# 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 - # 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 - cd /var/www/html - composer install --no-dev --optimize-autoloader - cd - - 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 -php /var/www/html/artisan queue:work --sleep=3 --tries=3 & +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 From dc1eca34ef2652909e55cdb6105cc99f98f5adb9 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 14 May 2024 14:52:56 +0200 Subject: [PATCH 19/73] ADD: warning on top of the developement docker readme --- docker/development/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/development/README.md b/docker/development/README.md index 1581bd17a..1838becbc 100644 --- a/docker/development/README.md +++ b/docker/development/README.md @@ -1,3 +1,5 @@ +โš  Caution: These instructions have not been updated since before version 1.0 of the project. Therefore, there may be inaccuracies, instability, or non-functional aspects. Proceed with care. (you may want to take a look at the standalone docker instread) + # Building the development environment cd into the project directory and run the following command: `sh bin/startdocker.sh` @@ -31,5 +33,3 @@ php artisan migrate:fresh --seed --env=testing Now when running tests with PHPUnit it will use your testing database and not your local development one. This is configured in the __phpunit.xml__. You can run your tests by running the command like this. Just type and enter. `php artisan test`. - - From 5dc6aabba81ebbde6122d47187f8dd2aa0d0e5b3 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 28 May 2024 10:55:06 +0200 Subject: [PATCH 20/73] UPDATED: updated the development docker to use the standalone one whit more tools --- docker/development/docker-compose.yml | 44 ++- docker/development/nginx/Dockerfile | 10 - docker/development/nginx/default.conf | 20 -- docker/development/nginx/nginx.conf | 29 -- docker/development/php/Dockerfile | 18 -- docker/development/php/www.conf | 439 -------------------------- 6 files changed, 21 insertions(+), 539 deletions(-) delete mode 100644 docker/development/nginx/Dockerfile delete mode 100644 docker/development/nginx/default.conf delete mode 100644 docker/development/nginx/nginx.conf delete mode 100644 docker/development/php/Dockerfile delete mode 100644 docker/development/php/www.conf diff --git a/docker/development/docker-compose.yml b/docker/development/docker-compose.yml index 16c9bf94f..4d31230a7 100644 --- a/docker/development/docker-compose.yml +++ b/docker/development/docker-compose.yml @@ -1,21 +1,20 @@ version: '3' -networks: - laravel: - +// TODO: add wings and pterodactyl services: - nginx: + + controlpanel_standalone: build: context: ../../ - dockerfile: docker/development/nginx/Dockerfile - container_name: controlpanel_nginx + dockerfile: ./docker/standalone/Dockerfile + container_name: controlpanel_standalone + restart: on-failure ports: - - 80:80 + - "80:80" + - "443:443" volumes: - - "../../:/var/www/html" - depends_on: - - php - - mysql + - './website_files:/var/www/html:rw' # change it to your project + - './nginx_config:/etc/nginx/conf.d/:rw' # change it networks: - laravel @@ -36,16 +35,6 @@ services: networks: - laravel - php: - build: - context: ../../ - dockerfile: docker/development/php/Dockerfile - container_name: controlpanel_php - volumes: - - "../../:/var/www/html" - networks: - - laravel - phpmyadmin: image: phpmyadmin/phpmyadmin container_name: controlpanel_phpmyadmin @@ -61,5 +50,14 @@ services: networks: - laravel -volumes: - mysql: \ No newline at end of file + redis: + image: redis + container_name: controlpanel_redis + restart: unless-stopped + ports: + - "6379:6379" + networks: + - laravel + +networks: + laravel: diff --git a/docker/development/nginx/Dockerfile b/docker/development/nginx/Dockerfile deleted file mode 100644 index deca865f1..000000000 --- a/docker/development/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/development/nginx/nginx.conf /etc/nginx/ -ADD ./docker/development/nginx/default.conf /etc/nginx/conf.d/ - -RUN mkdir -p /var/www/html - -RUN chown laravel:laravel /var/www/html diff --git a/docker/development/nginx/default.conf b/docker/development/nginx/default.conf deleted file mode 100644 index 282633d76..000000000 --- a/docker/development/nginx/default.conf +++ /dev/null @@ -1,20 +0,0 @@ -server { - listen 80; - index index.php index.html; - server_name _; - root /var/www/html/public; - - 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 fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - } -} diff --git a/docker/development/nginx/nginx.conf b/docker/development/nginx/nginx.conf deleted file mode 100644 index 060e50253..000000000 --- a/docker/development/nginx/nginx.conf +++ /dev/null @@ -1,29 +0,0 @@ -user laravel; -worker_processes auto; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; - - include /etc/nginx/conf.d/*.conf; -} diff --git a/docker/development/php/Dockerfile b/docker/development/php/Dockerfile deleted file mode 100644 index 3ec761ae7..000000000 --- a/docker/development/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/development/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/development/php/www.conf b/docker/development/php/www.conf deleted file mode 100644 index eb028e111..000000000 --- a/docker/development/php/www.conf +++ /dev/null @@ -1,439 +0,0 @@ -; Start a new pool named 'www'. -; the variable $pool can be used in any directive and will be replaced by the -; pool name ('www' here) -[www] - -; Per pool prefix -; It only applies on the following directives: -; - 'access.log' -; - 'slowlog' -; - 'listen' (unixsocket) -; - 'chroot' -; - 'chdir' -; - 'php_values' -; - 'php_admin_values' -; When not set, the global prefix (or NONE) applies instead. -; Note: This directive can also be relative to the global prefix. -; Default Value: none -;prefix = /path/to/pools/$pool - -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = laravel -group = laravel - -; The address on which to accept FastCGI requests. -; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on -; a specific port; -; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on -; a specific port; -; 'port' - to listen on a TCP socket to all addresses -; (IPv6 and IPv4-mapped) on a specific port; -; '/path/to/unix/socket' - to listen on a unix socket. -; Note: This value is mandatory. -listen = 127.0.0.1:9000 - -; Set listen(2) backlog. -; Default Value: 511 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 511 - -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. The owner -; and group can be specified either by name or by their numeric IDs. -; Default Values: user and group are set as the running user -; mode is set to 0660 -;listen.owner = www-data -;listen.group = www-data -;listen.mode = 0660 -; When POSIX Access Control Lists are supported you can set them using -; these options, value is a comma separated list of user/group names. -; When set, listen.owner and listen.group are ignored -;listen.acl_users = -;listen.acl_groups = - -; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. -; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original -; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address -; must be separated by a comma. If this value is left blank, connections will be -; accepted from any ip address. -; Default Value: any -;listen.allowed_clients = 127.0.0.1 - -; Specify the nice(2) priority to apply to the pool processes (only if set) -; The value can vary from -19 (highest priority) to 20 (lower priority) -; Note: - It will only work if the FPM master process is launched as root -; - The pool processes will inherit the master process priority -; unless it specified otherwise -; Default Value: no set -; process.priority = -19 - -; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user -; or group is differrent than the master process user. It allows to create process -; core dump and ptrace the process for the pool user. -; Default Value: no -; process.dumpable = yes - -; Choose how the process manager will control the number of child processes. -; Possible Values: -; static - a fixed number (pm.max_children) of child processes; -; dynamic - the number of child processes are set dynamically based on the -; following directives. With this process management, there will be -; always at least 1 children. -; pm.max_children - the maximum number of children that can -; be alive at the same time. -; pm.start_servers - the number of children created on startup. -; pm.min_spare_servers - the minimum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is less than this -; number then some children will be created. -; pm.max_spare_servers - the maximum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is greater than this -; number then some children will be killed. -; ondemand - no children are created at startup. Children will be forked when -; new requests will connect. The following parameter are used: -; pm.max_children - the maximum number of children that -; can be alive at the same time. -; pm.process_idle_timeout - The number of seconds after which -; an idle process will be killed. -; Note: This value is mandatory. -pm = dynamic - -; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. -; This value sets the limit on the number of simultaneous requests that will be -; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. -; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. The below defaults are based on a server without much resources. Don't -; forget to tweak pm.* to fit your needs. -; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' -; Note: This value is mandatory. -pm.max_children = 5 - -; The number of child processes created on startup. -; Note: Used only when pm is set to 'dynamic' -; Default Value: (min_spare_servers + max_spare_servers) / 2 -pm.start_servers = 2 - -; The desired minimum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 1 - -; The desired maximum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 3 - -; The number of seconds after which an idle process will be killed. -; Note: Used only when pm is set to 'ondemand' -; Default Value: 10s -;pm.process_idle_timeout = 10s; - -; The number of requests each child process should execute before respawning. -; This can be useful to work around memory leaks in 3rd party libraries. For -; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. -; Default Value: 0 -;pm.max_requests = 500 - -; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. It shows the following informations: -; pool - the name of the pool; -; process manager - static, dynamic or ondemand; -; start time - the date and time FPM has started; -; start since - number of seconds since FPM has started; -; accepted conn - the number of request accepted by the pool; -; listen queue - the number of request in the queue of pending -; connections (see backlog in listen(2)); -; max listen queue - the maximum number of requests in the queue -; of pending connections since FPM has started; -; listen queue len - the size of the socket queue of pending connections; -; idle processes - the number of idle processes; -; active processes - the number of active processes; -; total processes - the number of idle + active processes; -; max active processes - the maximum number of active processes since FPM -; has started; -; max children reached - number of times, the process limit has been reached, -; when pm tries to start more children (works only for -; pm 'dynamic' and 'ondemand'); -; Value are updated in real time. -; Example output: -; pool: www -; process manager: static -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 62636 -; accepted conn: 190460 -; listen queue: 0 -; max listen queue: 1 -; listen queue len: 42 -; idle processes: 4 -; active processes: 11 -; total processes: 15 -; max active processes: 12 -; max children reached: 0 -; -; By default the status page output is formatted as text/plain. Passing either -; 'html', 'xml' or 'json' in the query string will return the corresponding -; output syntax. Example: -; http://www.foo.bar/status -; http://www.foo.bar/status?json -; http://www.foo.bar/status?html -; http://www.foo.bar/status?xml -; -; By default the status page only outputs short status. Passing 'full' in the -; query string will also return status for each pool process. -; Example: -; http://www.foo.bar/status?full -; http://www.foo.bar/status?json&full -; http://www.foo.bar/status?html&full -; http://www.foo.bar/status?xml&full -; The Full status returns for each process: -; pid - the PID of the process; -; state - the state of the process (Idle, Running, ...); -; start time - the date and time the process has started; -; start since - the number of seconds since the process has started; -; requests - the number of requests the process has served; -; request duration - the duration in ยตs of the requests; -; request method - the request method (GET, POST, ...); -; request URI - the request URI with the query string; -; content length - the content length of the request (only with POST); -; user - the user (PHP_AUTH_USER) (or '-' if not set); -; script - the main script called (or '-' if not set); -; last request cpu - the %cpu the last request consumed -; it's always 0 if the process is not in Idle state -; because CPU calculation is done when the request -; processing has terminated; -; last request memory - the max amount of memory the last request consumed -; it's always 0 if the process is not in Idle state -; because memory calculation is done when the request -; processing has terminated; -; If the process is in Idle state, then informations are related to the -; last request the process has served. Otherwise informations are related to -; the current request being served. -; Example output: -; ************************ -; pid: 31330 -; state: Running -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 63087 -; requests: 12808 -; request duration: 1250261 -; request method: GET -; request URI: /test_mem.php?N=10000 -; content length: 0 -; user: - -; script: /home/fat/web/docs/php/test_mem.php -; last request cpu: 0.00 -; last request memory: 0 -; -; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: /usr/local/share/php/fpm/status.html -; -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;pm.status_path = /status - -; The ping URI to call the monitoring page of FPM. If this value is not set, no -; URI will be recognized as a ping page. This could be used to test from outside -; that FPM is alive and responding, or to -; - create a graph of FPM availability (rrd or such); -; - remove a server from a group if it is not responding (load balancing); -; - trigger alerts for the operating team (24/7). -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;ping.path = /ping - -; This directive may be used to customize the response of a ping request. The -; response is formatted as text/plain with a 200 response code. -; Default Value: pong -;ping.response = pong - -; The access log file -; Default: not set -;access.log = log/$pool.access.log - -; The access log format. -; The following syntax is allowed -; %%: the '%' character -; %C: %CPU used by the request -; it can accept the following format: -; - %{user}C for user CPU only -; - %{system}C for system CPU only -; - %{total}C for user + system CPU (default) -; %d: time taken to serve the request -; it can accept the following format: -; - %{seconds}d (default) -; - %{miliseconds}d -; - %{mili}d -; - %{microseconds}d -; - %{micro}d -; %e: an environment variable (same as $_ENV or $_SERVER) -; it must be associated with embraces to specify the name of the env -; variable. Some exemples: -; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e -; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e -; %f: script filename -; %l: content-length of the request (for POST request only) -; %m: request method -; %M: peak of memory allocated by PHP -; it can accept the following format: -; - %{bytes}M (default) -; - %{kilobytes}M -; - %{kilo}M -; - %{megabytes}M -; - %{mega}M -; %n: pool name -; %o: output header -; it must be associated with embraces to specify the name of the header: -; - %{Content-Type}o -; - %{X-Powered-By}o -; - %{Transfert-Encoding}o -; - .... -; %p: PID of the child that serviced the request -; %P: PID of the parent of the child that serviced the request -; %q: the query string -; %Q: the '?' character if query string exists -; %r: the request URI (without the query string, see %q and %Q) -; %R: remote IP address -; %s: status (response code) -; %t: server time the request was received -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t -; %T: time the log has been written (the request has finished) -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t -; %u: remote user -; -; Default: "%R - %u %t \"%m %r\" %s" -;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -;slowlog = log/$pool.log.slow - -; The timeout for serving a single request after which a PHP backtrace will be -; dumped to the 'slowlog' file. A value of '0s' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_slowlog_timeout = 0 - -; Depth of slow log stack trace. -; Default Value: 20 -;request_slowlog_trace_depth = 20 - -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_terminate_timeout = 0 - -; The timeout set by 'request_terminate_timeout' ini option is not engaged after -; application calls 'fastcgi_finish_request' or when application has finished and -; shutdown functions are being called (registered via register_shutdown_function). -; This option will enable timeout limit to be applied unconditionally -; even in such cases. -; Default Value: no -;request_terminate_timeout_track_finished = no - -; Set open file descriptor rlimit. -; Default Value: system defined value -;rlimit_files = 1024 - -; Set max core size rlimit. -; Possible Values: 'unlimited' or an integer greater or equal to 0 -; Default Value: system defined value -;rlimit_core = 0 - -; Chroot to this directory at the start. This value must be defined as an -; absolute path. When this value is not set, chroot is not used. -; Note: you can prefix with '$prefix' to chroot to the pool prefix or one -; of its subdirectories. If the pool prefix is not set, the global prefix -; will be used instead. -; Note: chrooting is a great security feature and should be used whenever -; possible. However, all PHP paths will be relative to the chroot -; (error_log, sessions.save_path, ...). -; Default Value: not set -;chroot = - -; Chdir to this directory at the start. -; Note: relative path can be used. -; Default Value: current directory or / when chroot -;chdir = /var/www - -; Redirect worker stdout and stderr into main error log. If not set, stdout and -; stderr will be redirected to /dev/null according to FastCGI specs. -; Note: on highloaded environement, this can cause some delay in the page -; process time (several ms). -; Default Value: no -;catch_workers_output = yes - -; Decorate worker output with prefix and suffix containing information about -; the child that writes to the log and if stdout or stderr is used as well as -; log level and time. This options is used only if catch_workers_output is yes. -; Settings to "no" will output data as written to the stdout or stderr. -; Default value: yes -;decorate_workers_output = no - -; Clear environment in FPM workers -; Prevents arbitrary environment variables from reaching FPM worker processes -; by clearing the environment in workers before env vars specified in this -; pool configuration are added. -; Setting to "no" will make all environment variables available to PHP code -; via getenv(), $_ENV and $_SERVER. -; Default Value: yes -;clear_env = no - -; Limits the extensions of the main script FPM will allow to parse. This can -; prevent configuration mistakes on the web server side. You should only limit -; FPM to .php extensions to prevent malicious users to use other extensions to -; execute php code. -; Note: set an empty value to allow all extensions. -; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 .php7 - -; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from -; the current environment. -; Default Value: clean env -;env[HOSTNAME] = $HOSTNAME -;env[PATH] = /usr/local/bin:/usr/bin:/bin -;env[TMP] = /tmp -;env[TMPDIR] = /tmp -;env[TEMP] = /tmp - -; Additional php.ini defines, specific to this pool of workers. These settings -; overwrite the values previously defined in the php.ini. The directives are the -; same as the PHP SAPI: -; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. -; php_admin_value/php_admin_flag - these directives won't be overwritten by -; PHP call 'ini_set' -; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. - -; Defining 'extension' will load the corresponding shared extension from -; extension_dir. Defining 'disable_functions' or 'disable_classes' will not -; overwrite previously defined php.ini values, but will append the new value -; instead. - -; Note: path INI options can be relative and will be expanded with the prefix -; (pool, global or /usr/local) - -; Default Value: nothing is defined by default except the values in php.ini and -; specified at startup with the -d argument -;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com -;php_flag[display_errors] = off -;php_admin_value[error_log] = /var/log/fpm-php.www.log -;php_admin_flag[log_errors] = on -;php_admin_value[memory_limit] = 32M From 984330a475a1f93599fb114421531dc5909fcbe7 Mon Sep 17 00:00:00 2001 From: S0ly Date: Tue, 28 May 2024 10:55:26 +0200 Subject: [PATCH 21/73] UPDATE: updated the readme of the developement docker --- docker/development/README.md | 42 +++++++++++++----------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/docker/development/README.md b/docker/development/README.md index 1838becbc..46f3f9c95 100644 --- a/docker/development/README.md +++ b/docker/development/README.md @@ -1,35 +1,23 @@ -โš  Caution: These instructions have not been updated since before version 1.0 of the project. Therefore, there may be inaccuracies, instability, or non-functional aspects. Proceed with care. (you may want to take a look at the standalone docker instread) +# ๐Ÿณ Docker Development Environment -# Building the development environment +This development environment utilizes standalone Docker with necessary tools pre-configured. -cd into the project directory and run the following command: `sh bin/startdocker.sh` -This should start building the images and start the containers. +## Included Services +- Redis +- MySQL +- Tools like phpMyAdmin -After that you need to go into the controlpanel_php container and run some commands: +## Not Included Services (for the moment) +- Pterodactyl +- Wings -Type `docker exec -it controlpanel_php ash` to go into the container and run the following commands: +Feel free to modify the Docker Compose file to remove any services you already have. -```shell -composer install -cp .env.example .env -php artisan key:generate --force -php artisan storage:link -php artisan migrate --seed --force -``` +## Setting Up the Testing Environment -## Setting up 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. -Create the .env.testing file to your needs. Then once done you need to go into your phpmyadmin to create a new database named __controlpanel_test__. -Visit http://127.0.0.1:8080/ and create your database. +For detailed setup instructions, refer to the standalone Docker documentation. -Now you're ready to run the following commands which switches to the testing config, migrates the test database and seeds it. -After that you can switch back to your dev environment again. Clear the config from cache so changes will be instantly available. - -```shell -php artisan key:generate --force --env=testing -php artisan migrate:fresh --seed --env=testing -``` - -Now when running tests with PHPUnit it will use your testing database and not your local development one. -This is configured in the __phpunit.xml__. You can run your tests by running the command like this. Just type and enter. -`php artisan test`. +โš  Caution: These instructions have not been finished. Therefore, there may be inaccuracies, instability, or non-functional aspects. Proceed with care. From 4e0370b051ecd82c895a93607bd69b23b4c41623 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Tue, 28 May 2024 21:55:01 +0200 Subject: [PATCH 22/73] Fix explode null parameter, Update dev docker compose file --- .../development/{docker-compose.yml => compose.yaml} | 11 ++++------- .../standalone/{docker-compose.yml => compose.yaml} | 0 2 files changed, 4 insertions(+), 7 deletions(-) rename docker/development/{docker-compose.yml => compose.yaml} (83%) rename docker/standalone/{docker-compose.yml => compose.yaml} (100%) diff --git a/docker/development/docker-compose.yml b/docker/development/compose.yaml similarity index 83% rename from docker/development/docker-compose.yml rename to docker/development/compose.yaml index 4d31230a7..e7169377e 100644 --- a/docker/development/docker-compose.yml +++ b/docker/development/compose.yaml @@ -1,8 +1,5 @@ -version: '3' - -// TODO: add wings and pterodactyl services: - + # TODO: add wings and pterodactyl controlpanel_standalone: build: context: ../../ @@ -13,8 +10,8 @@ services: - "80:80" - "443:443" volumes: - - './website_files:/var/www/html:rw' # change it to your project - - './nginx_config:/etc/nginx/conf.d/:rw' # change it + - '../..:/var/www/html:rw' + - './nginx_config:/etc/nginx/conf.d/:rw' networks: - laravel @@ -31,7 +28,7 @@ services: MYSQL_PASSWORD: root MYSQL_ROOT_PASSWORD: root volumes: - - "mysql:/var/lib/mysql:delegated" + - "./mysql:/var/lib/mysql:delegated" networks: - laravel diff --git a/docker/standalone/docker-compose.yml b/docker/standalone/compose.yaml similarity index 100% rename from docker/standalone/docker-compose.yml rename to docker/standalone/compose.yaml From 0596f7c78240e40de66b4f70dab6f539cb75347a Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Tue, 28 May 2024 22:03:37 +0200 Subject: [PATCH 23/73] Update gitignore, Fix explode null parameter --- .gitignore | 3 +++ config/trustedproxy.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ad9d095b8..aebb0fa86 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ storage/app/public/logo.png public/install/logs.txt install.lock public/install/logs/installer.log +public/install/logs/laravel.log +docker/development/nginx_config +docker/development/mysql diff --git a/config/trustedproxy.php b/config/trustedproxy.php index dc46c31ba..f3b88cd52 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -26,7 +26,7 @@ * subsequently passed through. */ 'proxies' => in_array(env('TRUSTED_PROXIES', []), ['*', '**']) ? - env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', null)), + env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', '')), /* * Or, to trust all proxies that connect From 78479a025d1621290412b90d18a7f52119c9b749 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Tue, 28 May 2024 22:43:11 +0200 Subject: [PATCH 24/73] Update dev compose.yml and gitignore --- .gitignore | 1 - docker/development/compose.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index aebb0fa86..ee0e3762a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,5 @@ storage/app/public/logo.png public/install/logs.txt install.lock public/install/logs/installer.log -public/install/logs/laravel.log docker/development/nginx_config docker/development/mysql diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index e7169377e..3fd698db7 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -4,7 +4,7 @@ services: build: context: ../../ dockerfile: ./docker/standalone/Dockerfile - container_name: controlpanel_standalone + container_name: controlpanel_development restart: on-failure ports: - "80:80" From 299416daa3e37251ca816d5e4447041d86377f9e Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Tue, 28 May 2024 23:05:17 +0200 Subject: [PATCH 25/73] Revert explode deprecation fix, move gitignore to apropriate folder --- .gitignore | 2 -- config/trustedproxy.php | 2 +- docker/development/.gitignore | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100755 docker/development/.gitignore diff --git a/.gitignore b/.gitignore index ee0e3762a..ad9d095b8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,3 @@ storage/app/public/logo.png public/install/logs.txt install.lock public/install/logs/installer.log -docker/development/nginx_config -docker/development/mysql diff --git a/config/trustedproxy.php b/config/trustedproxy.php index f3b88cd52..dc46c31ba 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -26,7 +26,7 @@ * subsequently passed through. */ 'proxies' => in_array(env('TRUSTED_PROXIES', []), ['*', '**']) ? - env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', '')), + env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', null)), /* * Or, to trust all proxies that connect 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 From 3a7dc46d94a983d5ffab2acc067029e8e1f971c7 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 09:00:40 +0200 Subject: [PATCH 26/73] Add docker build workflow --- .github/workflows/docker-build.yml | 93 ++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..166fc8abd --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,93 @@ +name: Build and Push Docker Images + +on: + push: + branches: + - main + - docker-github-workflow + tags: + - '*' + +jobs: + build-and-push-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 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + +#name: Build and Push Docker Images +# +#on: +# push: +# branches: +# - main +# tags: +# - '*' +# +#env: +# REGISTRY: ghcr.io +# IMAGE_NAME: ${{ github.repository }} +# +#jobs: +# build-and-push-image: +# runs-on: ubuntu-latest +# permissions: +# contents: read +# packages: write +# +# steps: +# - name: Checkout repository +# uses: actions/checkout@v3 +# +# - name: Log in to the Container registry +# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ github.actor }} +# password: ${{ secrets.GITHUB_TOKEN }} +# +# - name: Extract metadata (tags, labels) for Docker +# id: meta +# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 +# with: +# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} +# +# - name: Build and push Docker image +# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 +# with: +# context: . +# target: ${{ env.IMAGE_NAME }} +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} From aa5820cfe922c1a087e42591e2d3a0c6fc14bc53 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 09:02:38 +0200 Subject: [PATCH 27/73] Add Dockerfile location to github workflow --- .github/workflows/docker-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 166fc8abd..70d0c9c05 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -41,6 +41,7 @@ jobs: with: context: . push: true + file: docker/standalone/Dockerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 1968a977bf2f79044298da04d8d653d366f12315 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 09:22:53 +0200 Subject: [PATCH 28/73] Update standalone compose file --- .github/workflows/docker-build.yml | 55 +-------------------------- docker/development/compose.yaml | 12 +++--- docker/standalone/compose.yaml | 61 ++++++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 67 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 70d0c9c05..54016c792 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,15 +1,12 @@ -name: Build and Push Docker Images +name: Build and Push Docker Image on: push: - branches: - - main - - docker-github-workflow tags: - '*' jobs: - build-and-push-image: + build-and-push-docker-image: runs-on: ubuntu-latest permissions: contents: read @@ -44,51 +41,3 @@ jobs: file: docker/standalone/Dockerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - - -#name: Build and Push Docker Images -# -#on: -# push: -# branches: -# - main -# tags: -# - '*' -# -#env: -# REGISTRY: ghcr.io -# IMAGE_NAME: ${{ github.repository }} -# -#jobs: -# build-and-push-image: -# runs-on: ubuntu-latest -# permissions: -# contents: read -# packages: write -# -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 -# -# - name: Log in to the Container registry -# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 -# with: -# registry: ${{ env.REGISTRY }} -# username: ${{ github.actor }} -# password: ${{ secrets.GITHUB_TOKEN }} -# -# - name: Extract metadata (tags, labels) for Docker -# id: meta -# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 -# with: -# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} -# -# - name: Build and push Docker image -# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 -# with: -# context: . -# target: ${{ env.IMAGE_NAME }} -# push: true -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index 3fd698db7..c3010c59f 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -1,6 +1,6 @@ services: # TODO: add wings and pterodactyl - controlpanel_standalone: + controlpanel_panel: build: context: ../../ dockerfile: ./docker/standalone/Dockerfile @@ -13,7 +13,7 @@ services: - '../..:/var/www/html:rw' - './nginx_config:/etc/nginx/conf.d/:rw' networks: - - laravel + - controlpanel mysql: image: mysql @@ -30,7 +30,7 @@ services: volumes: - "./mysql:/var/lib/mysql:delegated" networks: - - laravel + - controlpanel phpmyadmin: image: phpmyadmin/phpmyadmin @@ -45,7 +45,7 @@ services: - PMA_PASSWORD=root - PMA_ARBITRARY=1 networks: - - laravel + - controlpanel redis: image: redis @@ -54,7 +54,7 @@ services: ports: - "6379:6379" networks: - - laravel + - controlpanel networks: - laravel: + controlpanel: diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index cd980a2af..11b3dd85d 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -1,15 +1,60 @@ -version: '3' - services: - controlpanel_standalone: - build: - context: ../../ - dockerfile: ./docker/standalone/Dockerfile - container_name: controlpanel_standalone - restart: on-failure + controlpanel: + image: ghcr.io/jameskitt616/panel:latest + container_name: controlpanel_panel + restart: unless-stopped + depends_on: + - redis ports: - "80:80" - "443:443" volumes: - './website_files:/var/www/html:rw' # change it - './nginx_config:/etc/nginx/conf.d/:rw' # change it + networks: + - controlpanel + + mysql: + image: mysql + container_name: controlpanel_mysql + restart: unless-stopped + tty: true + ports: + - "3306:3306" + environment: + MYSQL_DATABASE: controlpanel + MYSQL_USER: controlpaneluser + MYSQL_PASSWORD: root # change it + MYSQL_ROOT_PASSWORD: root # change it + volumes: + - "./mysql:/var/lib/mysql:delegated" + networks: + - controlpanel + + phpmyadmin: + image: phpmyadmin/phpmyadmin + container_name: controlpanel_phpmyadmin + restart: unless-stopped + depends_on: + - mysql + ports: + - '8080:80' + environment: + - PMA_HOST=controlpanel_mysql + - PMA_USER=root # change it + - PMA_PASSWORD=root # change it + - PMA_ARBITRARY=1 + networks: + - controlpanel + + redis: + image: redis + container_name: controlpanel_redis + restart: unless-stopped + ports: + - "6379:6379" + networks: + - controlpanel + +networks: + controlpanel: From 93fb0b7d5e523900aa25a4a1710d228dd676cffa Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 09:28:06 +0200 Subject: [PATCH 29/73] Change repository owner name --- docker/standalone/compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 11b3dd85d..ba129fa4d 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -1,6 +1,6 @@ services: controlpanel: - image: ghcr.io/jameskitt616/panel:latest + image: ghcr.io/ctrlpanel-gg/panel:latest container_name: controlpanel_panel restart: unless-stopped depends_on: From 9fef8ab964a22bbd55e0e7e63abe96ef5980c11f Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 09:40:44 +0200 Subject: [PATCH 30/73] Update docker readme --- docker/standalone/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/standalone/README.md b/docker/standalone/README.md index 992b80c82..489c079d5 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -7,8 +7,15 @@ If you're using a different operating system, you can follow the official Docker Once you have Docker installed, you can run CtrlPanel standalone Docker by executing the following command: +Recommended way via Docker Compose: + +Get the Compose file [here](https://github.com/Ctrlpanel-gg/panel/blob/docker-github-workflow/docker/standalone/compose.yaml). +This also includes all necessaries like a Database, Redis and optionally phpmyadmin to manage the Database. + +Running as commandline command: + ```bash -docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html -v /path/to/nginx_config:/etc/nginx/conf.d/ ctrlpanel/ctrlpanel +docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html -v /path/to/nginx_config:/etc/nginx/conf.d/ ghcr.io/ctrlpanel-gg/panel:latest ``` This command will run the latest CtrlPanel Docker image from Docker Hub and run it. From 7a40c3837035af57e808bb99b02b83961e029e95 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 09:46:50 +0200 Subject: [PATCH 31/73] Update docker readme with redis instructions --- docker/standalone/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/standalone/README.md b/docker/standalone/README.md index 489c079d5..200234bf6 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -18,6 +18,8 @@ Running as commandline command: docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html -v /path/to/nginx_config:/etc/nginx/conf.d/ ghcr.io/ctrlpanel-gg/panel:latest ``` +When installing you need to update the `.env` 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. + This command will run the latest CtrlPanel Docker image from Docker Hub and run it. The control panel will be available at http://localhost/install and will be a completely fresh installation. From 86de9ecc4cf4f177e4edb05e6917ecff202c640c Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 12:56:20 +0200 Subject: [PATCH 32/73] Update startup script --- config/trustedproxy.php | 2 +- docker/development/compose.yaml | 4 +--- docker/standalone/compose.yaml | 10 ++++++---- docker/standalone/scripts/startup.sh | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/trustedproxy.php b/config/trustedproxy.php index dc46c31ba..f3b88cd52 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -26,7 +26,7 @@ * subsequently passed through. */ 'proxies' => in_array(env('TRUSTED_PROXIES', []), ['*', '**']) ? - env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', null)), + env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', '')), /* * Or, to trust all proxies that connect diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index c3010c59f..0c9e49ff5 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -5,15 +5,13 @@ services: context: ../../ dockerfile: ./docker/standalone/Dockerfile container_name: controlpanel_development - restart: on-failure + restart: unless-stopped ports: - "80:80" - "443:443" volumes: - '../..:/var/www/html:rw' - './nginx_config:/etc/nginx/conf.d/:rw' - networks: - - controlpanel mysql: image: mysql diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index ba129fa4d..51d9a9959 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -9,10 +9,12 @@ services: - "80:80" - "443:443" volumes: - - './website_files:/var/www/html:rw' # change it - - './nginx_config:/etc/nginx/conf.d/:rw' # change it - networks: - - controlpanel + - './env:/var/www/html/.env:rw' + - './logs:/var/www/html/storage/logs:rw' +# - './website_files:/var/www/html:rw' # change it +# - './nginx_config:/etc/nginx/conf.d/:rw' # change it +# networks: +# - controlpanel mysql: image: mysql diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 5f36512d9..17a36203f 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -32,6 +32,7 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 + chmod -R 644 $LOG_DIR fi # Check and copy default Nginx configuration if not exists From 47cdd8e17c2739e78fc06944d0fe2abd2de49200 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 13:04:10 +0200 Subject: [PATCH 33/73] Add network to dev compose --- docker/development/compose.yaml | 2 ++ docker/standalone/compose.yaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index 0c9e49ff5..ef2c3c2e1 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -12,6 +12,8 @@ services: volumes: - '../..:/var/www/html:rw' - './nginx_config:/etc/nginx/conf.d/:rw' + networks: + - controlpanel mysql: image: mysql diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 51d9a9959..960b14bdb 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -13,8 +13,8 @@ services: - './logs:/var/www/html/storage/logs:rw' # - './website_files:/var/www/html:rw' # change it # - './nginx_config:/etc/nginx/conf.d/:rw' # change it -# networks: -# - controlpanel + networks: + - controlpanel mysql: image: mysql From 956e6793742bb40ad0f6264d5a8e68821ec39ebc Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 13:08:53 +0200 Subject: [PATCH 34/73] Set database name and user to defaults from installer --- docker/development/compose.yaml | 4 ++-- docker/standalone/compose.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index ef2c3c2e1..7f5acb0f8 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -23,8 +23,8 @@ services: ports: - "3306:3306" environment: - MYSQL_DATABASE: controlpanel - MYSQL_USER: controlpanel + MYSQL_DATABASE: ctrlpanel + MYSQL_USER: ctrlpaneluser MYSQL_PASSWORD: root MYSQL_ROOT_PASSWORD: root volumes: diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 960b14bdb..0551eb61d 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -24,8 +24,8 @@ services: ports: - "3306:3306" environment: - MYSQL_DATABASE: controlpanel - MYSQL_USER: controlpaneluser + MYSQL_DATABASE: ctrlpanel + MYSQL_USER: ctrlpaneluser MYSQL_PASSWORD: root # change it MYSQL_ROOT_PASSWORD: root # change it volumes: From e054cb9a33036e418ce5d36d062647071ae336d1 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 13:29:30 +0200 Subject: [PATCH 35/73] Update permissions --- docker/standalone/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 17a36203f..39092d919 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -32,7 +32,7 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 - chmod -R 644 $LOG_DIR + chmod -R 664 $LOG_DIR fi # Check and copy default Nginx configuration if not exists From b3862a48e03511dfc3cf9c98dcd700bfdf418980 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 14:07:05 +0200 Subject: [PATCH 36/73] Try to determine if process is running within a docker container --- public/install/functions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/install/functions.php b/public/install/functions.php index a5f2b0454..046ea1a6f 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -236,14 +236,18 @@ function run_console(string $command, array $descriptors = null, string $cwd = n $path = dirname(__FILE__, 3); $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; - $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); + if (file_exists('/.dockerenv')) { + $handle = proc_open("cd '$path' && bash -c '$command'", $descriptors, $pipes, $cwd, null, $options); + } else { + $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); + } + $output = stream_get_contents($pipes[1]); $exit_code = proc_close($handle); if ($exit_code > 0) { wh_log('command result: ' . $output, 'error'); throw new Exception("There was an error after running command `$command`", $exit_code); - return $output; } else { return $output; } From aadd164d55255b342894d9db99501ae7a71b2150 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 14:27:16 +0200 Subject: [PATCH 37/73] Force conecole command without exec -a --- public/install/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/install/functions.php b/public/install/functions.php index 046ea1a6f..51b4c629e 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -236,11 +236,11 @@ function run_console(string $command, array $descriptors = null, string $cwd = n $path = dirname(__FILE__, 3); $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; - if (file_exists('/.dockerenv')) { +// if (file_exists('/.dockerenv')) { $handle = proc_open("cd '$path' && bash -c '$command'", $descriptors, $pipes, $cwd, null, $options); - } else { - $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); - } +// } else { +// $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); +// } $output = stream_get_contents($pipes[1]); $exit_code = proc_close($handle); From e564a3886062ba9d86312d05c7f8ec19dbf94aca Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 14:44:01 +0200 Subject: [PATCH 38/73] Comment out everything in run_console command --- public/install/functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/public/install/functions.php b/public/install/functions.php index 51b4c629e..5a964bf3e 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -235,15 +235,20 @@ function run_console(string $command, array $descriptors = null, string $cwd = n wh_log('running command: ' . $command, 'debug'); $path = dirname(__FILE__, 3); - $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + wh_log('running command: ' . "cd '$path' && bash -c '$command'", 'debug'); + +// $path = dirname(__FILE__, 3); +// $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; // if (file_exists('/.dockerenv')) { - $handle = proc_open("cd '$path' && bash -c '$command'", $descriptors, $pipes, $cwd, null, $options); +// $handle = proc_open("cd '$path' && bash -c '$command'", $descriptors, $pipes, $cwd, null, $options); // } else { // $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); // } - $output = stream_get_contents($pipes[1]); - $exit_code = proc_close($handle); +// $output = stream_get_contents($pipes[1]); +// $exit_code = proc_close($handle); + $exit_code = 0; + $output = 'yippie'; if ($exit_code > 0) { wh_log('command result: ' . $output, 'error'); From b8d6d59d14179abd5a616f3959b5bff6226d39e4 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 14:58:16 +0200 Subject: [PATCH 39/73] Set different permissions --- config/logging.php | 6 +++--- public/install/functions.php | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/config/logging.php b/config/logging.php index 5d4134ffa..a09c721f7 100644 --- a/config/logging.php +++ b/config/logging.php @@ -61,7 +61,7 @@ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), - 'permission' => 0664, + 'permission' => 0644, ], 'daily' => [ @@ -69,7 +69,7 @@ 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, - 'permission' => 0664, + 'permission' => 0644, ], 'slack' => [ @@ -118,7 +118,7 @@ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), - 'permission' => 0664, + 'permission' => 0644, ], ], diff --git a/public/install/functions.php b/public/install/functions.php index 5a964bf3e..519a88414 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -237,18 +237,17 @@ function run_console(string $command, array $descriptors = null, string $cwd = n $path = dirname(__FILE__, 3); wh_log('running command: ' . "cd '$path' && bash -c '$command'", 'debug'); -// $path = dirname(__FILE__, 3); -// $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + $path = dirname(__FILE__, 3); + $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; // if (file_exists('/.dockerenv')) { +// if (!file_exists('../../.env')) { // $handle = proc_open("cd '$path' && bash -c '$command'", $descriptors, $pipes, $cwd, null, $options); // } else { -// $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); + $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); // } -// $output = stream_get_contents($pipes[1]); -// $exit_code = proc_close($handle); - $exit_code = 0; - $output = 'yippie'; + $output = stream_get_contents($pipes[1]); + $exit_code = proc_close($handle); if ($exit_code > 0) { wh_log('command result: ' . $output, 'error'); From c5ad334b2bea7ed5bb466f56994c5729bf8f52b0 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 14:59:26 +0200 Subject: [PATCH 40/73] Set different permissions --- docker/standalone/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 39092d919..17a36203f 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -32,7 +32,7 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 - chmod -R 664 $LOG_DIR + chmod -R 644 $LOG_DIR fi # Check and copy default Nginx configuration if not exists From 92c16559ddc7905d9c1897ae2fa613687b20f3bc Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 15:12:20 +0200 Subject: [PATCH 41/73] Open up permissions --- config/logging.php | 6 +++--- docker/standalone/scripts/startup.sh | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/logging.php b/config/logging.php index a09c721f7..dc1ce25da 100644 --- a/config/logging.php +++ b/config/logging.php @@ -61,7 +61,7 @@ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), - 'permission' => 0644, + 'permission' => 0777, ], 'daily' => [ @@ -69,7 +69,7 @@ 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, - 'permission' => 0644, + 'permission' => 0777, ], 'slack' => [ @@ -118,7 +118,7 @@ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), - 'permission' => 0644, + 'permission' => 0777, ], ], diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 17a36203f..144350ef5 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -32,9 +32,10 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 - chmod -R 644 $LOG_DIR fi +chmod -R 777 $LOG_DIR + # 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..." From fec23eec1f1fbe5f9e9268bb40c0ef78d074d351 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 15:26:25 +0200 Subject: [PATCH 42/73] Revert stuff in functions.php --- docker/standalone/scripts/startup.sh | 3 ++- public/install/functions.php | 10 +--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 144350ef5..b4ab19552 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -34,7 +34,8 @@ if [ -z "$(ls -A /var/www/html)" ]; then chmod -R 755 /var/www/html fi -chmod -R 777 $LOG_DIR +#chmod -R 755 /var/www/html +#chmod -R 777 $LOG_DIR # Check and copy default Nginx configuration if not exists if [ ! -f "/etc/nginx/conf.d/default.conf" ]; then diff --git a/public/install/functions.php b/public/install/functions.php index 519a88414..7b482732f 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -234,17 +234,9 @@ function run_console(string $command, array $descriptors = null, string $cwd = n { wh_log('running command: ' . $command, 'debug'); - $path = dirname(__FILE__, 3); - wh_log('running command: ' . "cd '$path' && bash -c '$command'", 'debug'); - $path = dirname(__FILE__, 3); $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; -// if (file_exists('/.dockerenv')) { -// if (!file_exists('../../.env')) { -// $handle = proc_open("cd '$path' && bash -c '$command'", $descriptors, $pipes, $cwd, null, $options); -// } else { - $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); -// } + $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); $output = stream_get_contents($pipes[1]); $exit_code = proc_close($handle); From 786bac37ffa79c30a3dbc01a605364facd5aafc9 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 15:38:47 +0200 Subject: [PATCH 43/73] Reset permissions --- config/logging.php | 6 +++--- public/install/functions.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/logging.php b/config/logging.php index dc1ce25da..5d4134ffa 100644 --- a/config/logging.php +++ b/config/logging.php @@ -61,7 +61,7 @@ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), - 'permission' => 0777, + 'permission' => 0664, ], 'daily' => [ @@ -69,7 +69,7 @@ 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, - 'permission' => 0777, + 'permission' => 0664, ], 'slack' => [ @@ -118,7 +118,7 @@ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), - 'permission' => 0777, + 'permission' => 0664, ], ], diff --git a/public/install/functions.php b/public/install/functions.php index 7b482732f..912a90180 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -237,7 +237,6 @@ function run_console(string $command, array $descriptors = null, string $cwd = n $path = dirname(__FILE__, 3); $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); - $output = stream_get_contents($pipes[1]); $exit_code = proc_close($handle); From a2e0109e9df3c00882dadcd3c73a27b086d5011c Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 15:42:52 +0200 Subject: [PATCH 44/73] Update permissions in startup.sh --- docker/standalone/scripts/startup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index b4ab19552..dc1585995 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -30,11 +30,11 @@ if [ -z "$(ls -A /var/www/html)" ]; 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 +# chown -R laravel:laravel /var/www/html/ +# chmod -R 755 /var/www/html fi -#chmod -R 755 /var/www/html +chmod -R 755 /var/www/html #chmod -R 777 $LOG_DIR # Check and copy default Nginx configuration if not exists From 76463c940bb787d8ef3473e0d533724ac02944fe Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 15:55:45 +0200 Subject: [PATCH 45/73] Add chown to startup.sh --- docker/standalone/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index dc1585995..b44b959dc 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -34,8 +34,8 @@ if [ -z "$(ls -A /var/www/html)" ]; then # chmod -R 755 /var/www/html fi +chown -R laravel:laravel /var/www/html/ chmod -R 755 /var/www/html -#chmod -R 777 $LOG_DIR # Check and copy default Nginx configuration if not exists if [ ! -f "/etc/nginx/conf.d/default.conf" ]; then From dffcb25afe746fe9f24ee03456a32db138f3eeae Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 16:21:05 +0200 Subject: [PATCH 46/73] Add permissions to streamhandler --- docker/standalone/Dockerfile | 3 +++ docker/standalone/compose.yaml | 6 +++--- docker/standalone/scripts/startup.sh | 8 ++++---- public/install/functions.php | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index a16bed8cb..9fd5e4770 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -58,5 +58,8 @@ RUN chmod +x /usr/local/bin/startup-script.sh # Set the working directory WORKDIR /var/www/html +#RUN chmod -R 755 /var/www/html +#RUN chown -R laravel:laravel /var/www/html + # Start the startup script CMD ["/usr/local/bin/startup-script.sh"] diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 0551eb61d..6b00f27df 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -9,9 +9,9 @@ services: - "80:80" - "443:443" volumes: - - './env:/var/www/html/.env:rw' - - './logs:/var/www/html/storage/logs:rw' -# - './website_files:/var/www/html:rw' # change it +# - './env:/var/www/html/.env:rw' +# - './logs:/var/www/html/storage/logs:rw' + - './website_files:/var/www/html:rw' # change it # - './nginx_config:/etc/nginx/conf.d/:rw' # change it networks: - controlpanel diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index b44b959dc..3bfa5f212 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -30,12 +30,12 @@ if [ -z "$(ls -A /var/www/html)" ]; 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 + chown -R laravel:laravel /var/www/html/ + chmod -R 755 /var/www/html/ fi -chown -R laravel:laravel /var/www/html/ -chmod -R 755 /var/www/html +#chown -R laravel:laravel /var/www/html/ +#chmod -R 755 /var/www/html/ # Check and copy default Nginx configuration if not exists if [ ! -f "/etc/nginx/conf.d/default.conf" ]; then diff --git a/public/install/functions.php b/public/install/functions.php index 912a90180..e44d2f3c1 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -258,7 +258,7 @@ function run_console(string $command, array $descriptors = null, string $cwd = n function wh_log(string $message, string $level = 'info', array $context = []): void { $formatter = new LineFormatter(null, null, true, true); - $stream = new StreamHandler(dirname(__FILE__, 3) . '/storage/logs/installer.log', Logger::DEBUG); + $stream = new StreamHandler(dirname(__FILE__, 3) . '/storage/logs/installer.log', Logger::DEBUG, true, 664); $stream->setFormatter($formatter); $log = new Logger('ControlPanel'); From 0a3cc259640ed1156553d3e3846b631ee0ef7c9a Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 16:41:16 +0200 Subject: [PATCH 47/73] Revert StreamHandler permissions --- docker/standalone/Dockerfile | 3 --- docker/standalone/scripts/startup.sh | 4 ++-- public/install/functions.php | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 9fd5e4770..a16bed8cb 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -58,8 +58,5 @@ RUN chmod +x /usr/local/bin/startup-script.sh # Set the working directory WORKDIR /var/www/html -#RUN chmod -R 755 /var/www/html -#RUN chown -R laravel:laravel /var/www/html - # Start the startup script CMD ["/usr/local/bin/startup-script.sh"] diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 3bfa5f212..57e7195da 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -34,8 +34,8 @@ if [ -z "$(ls -A /var/www/html)" ]; then chmod -R 755 /var/www/html/ fi -#chown -R laravel:laravel /var/www/html/ -#chmod -R 755 /var/www/html/ +chown -R laravel:laravel /var/www/html/ +chmod -R 755 /var/www/html/ # Check and copy default Nginx configuration if not exists if [ ! -f "/etc/nginx/conf.d/default.conf" ]; then diff --git a/public/install/functions.php b/public/install/functions.php index e44d2f3c1..912a90180 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -258,7 +258,7 @@ function run_console(string $command, array $descriptors = null, string $cwd = n function wh_log(string $message, string $level = 'info', array $context = []): void { $formatter = new LineFormatter(null, null, true, true); - $stream = new StreamHandler(dirname(__FILE__, 3) . '/storage/logs/installer.log', Logger::DEBUG, true, 664); + $stream = new StreamHandler(dirname(__FILE__, 3) . '/storage/logs/installer.log', Logger::DEBUG); $stream->setFormatter($formatter); $log = new Logger('ControlPanel'); From d6a01b66f1c8d9453be7cd888d5f85decfe945d3 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 16:41:44 +0200 Subject: [PATCH 48/73] Revert trustedpries --- config/trustedproxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/trustedproxy.php b/config/trustedproxy.php index f3b88cd52..dc46c31ba 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -26,7 +26,7 @@ * subsequently passed through. */ 'proxies' => in_array(env('TRUSTED_PROXIES', []), ['*', '**']) ? - env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', '')), + env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES', null)), /* * Or, to trust all proxies that connect From f523ea6f2b09035682853b6eb103c5b641f73fc4 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Thu, 30 May 2024 17:05:36 +0200 Subject: [PATCH 49/73] Revert permissions in startup.sh --- docker/standalone/scripts/startup.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 57e7195da..5f36512d9 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -31,12 +31,9 @@ if [ -z "$(ls -A /var/www/html)" ]; then # 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/ + chmod -R 755 /var/www/html fi -chown -R laravel:laravel /var/www/html/ -chmod -R 755 /var/www/html/ - # 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..." From c285f8f0944d3d1c6e46e1f5f5eb382b08c5de5a Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 1 Jun 2024 09:47:05 +0200 Subject: [PATCH 50/73] Copy .env file in Dockerfile --- docker/standalone/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index a16bed8cb..5880acee2 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -50,6 +50,9 @@ RUN mkdir -p /var/log/nginx && chown -R laravel:laravel /var/log/nginx # Expose ports EXPOSE 80 443 +# Copy .env file for it to be availbe when starting the Docker container (to be able to bind-mount it to the host, instead of the entire project folder) +COPY --chown=laravel:laravel ./.env.example /var/www/html/.env + # Copy startup script COPY --chown=laravel:laravel ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh # Make startup script executable @@ -58,5 +61,6 @@ 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"] From bdffb660ccdf044b13947ce9876c8de97ce12b10 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 1 Jun 2024 10:22:25 +0200 Subject: [PATCH 51/73] copy env file in startup script --- docker/standalone/Dockerfile | 5 ++--- docker/standalone/scripts/startup.sh | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 5880acee2..474b7a98e 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -50,8 +50,8 @@ RUN mkdir -p /var/log/nginx && chown -R laravel:laravel /var/log/nginx # Expose ports EXPOSE 80 443 -# Copy .env file for it to be availbe when starting the Docker container (to be able to bind-mount it to the host, instead of the entire project folder) -COPY --chown=laravel:laravel ./.env.example /var/www/html/.env +# 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) +#COPY --chown=laravel:laravel /var/default/.env.example /var/www/html/.env # Copy startup script COPY --chown=laravel:laravel ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh @@ -61,6 +61,5 @@ 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/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 5f36512d9..fd70d3151 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -34,6 +34,9 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 -nr /var/www/html/.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..." From d6d5fd878b689898e46aa9343bd523858ae33912 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 1 Jun 2024 10:26:29 +0200 Subject: [PATCH 52/73] Copy .env.example from different dir --- docker/standalone/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index fd70d3151..ee90e2152 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -35,7 +35,7 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 -nr /var/www/html/.env.example /var/www/html/.env # Use -n to avoid overwriting existing files +cp -nr /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 From 318781f95426dc718f58940b9d464fb55f0719d8 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 2 Jun 2024 08:45:34 +0200 Subject: [PATCH 53/73] Remove reverse parameter from copy single file --- docker/standalone/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index ee90e2152..b90814719 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -35,7 +35,7 @@ if [ -z "$(ls -A /var/www/html)" ]; then 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 -nr /var/default/.env.example /var/www/html/.env # Use -n to avoid overwriting existing files +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 From bba697b713eb218d4b8477e91c298fc5978d8acd Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 2 Jun 2024 09:17:32 +0200 Subject: [PATCH 54/73] Create dir on startup script --- docker/standalone/scripts/startup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index b90814719..c67494bdc 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -25,6 +25,8 @@ log_message() { echo "$1" } +mkdir /var/www/html/ + # Check if project folder is empty. if [ -z "$(ls -A /var/www/html)" ]; then log_message "Warning: project folder is empty. Copying default files..." From 9cffe584b0408f3fbfc4704b2e5dfb2d849f805f Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 2 Jun 2024 09:23:09 +0200 Subject: [PATCH 55/73] Run copy of project files every time --- docker/standalone/scripts/startup.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index c67494bdc..37af86690 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -25,16 +25,14 @@ log_message() { echo "$1" } -mkdir /var/www/html/ - # Check if project folder is empty. -if [ -z "$(ls -A /var/www/html)" ]; then +#if [ -z "$(ls -A /var/www/html)" ]; 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 +#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 From a51ff578f43d99cb7ce8cf5c20f725fda8779175 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 2 Jun 2024 09:34:27 +0200 Subject: [PATCH 56/73] ls project dirs to check if they are empty --- docker/standalone/scripts/startup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 37af86690..1055d685a 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -25,14 +25,20 @@ log_message() { echo "$1" } +log_message "Contents of /var/default:" +ls -l /var/default + # Check if project folder is empty. -#if [ -z "$(ls -A /var/www/html)" ]; then +if [ -z "$(ls -A /var/www/html)" ]; 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 +fi + +log_message "Contents of /var/www/html:" +ls -l /var/www/html # 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 From 7c3d70285f0b3c2a0255e58ce2c542df0b761443 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 2 Jun 2024 09:43:10 +0200 Subject: [PATCH 57/73] Show and set permissions for project folder --- docker/standalone/scripts/startup.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 1055d685a..99380da14 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -26,19 +26,24 @@ log_message() { } log_message "Contents of /var/default:" -ls -l /var/default +ls -la /var/default + +log_message "Permissions of /var/www/html:" +ls -la /var/www/html # Check if project folder is empty. if [ -z "$(ls -A /var/www/html)" ]; then + chown -R laravel:laravel /var/www/html/ + chmod -R 777 /var/www/html/ 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 + chmod -R 755 /var/www/html/ fi log_message "Contents of /var/www/html:" -ls -l /var/www/html +ls -la /var/www/html # 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 From 4c833e2f5cf590c2722d54447225109b05e6b6ce Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 2 Jun 2024 10:31:39 +0200 Subject: [PATCH 58/73] Run copy project files anyways --- docker/standalone/scripts/startup.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 99380da14..e909ebcce 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -31,16 +31,24 @@ ls -la /var/default log_message "Permissions of /var/www/html:" ls -la /var/www/html +chown -R laravel:laravel /var/www/html/ +chmod -R 777 /var/www/html/ +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/ + # Check if project folder is empty. -if [ -z "$(ls -A /var/www/html)" ]; then - chown -R laravel:laravel /var/www/html/ - chmod -R 777 /var/www/html/ - 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 +#if [ -z "$(ls -A /var/www/html)" ]; then +# chown -R laravel:laravel /var/www/html/ +# chmod -R 777 /var/www/html/ +# 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 log_message "Contents of /var/www/html:" ls -la /var/www/html From 863299b4c08e17292aa91d179a8162757bba61f5 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:23:41 +0200 Subject: [PATCH 59/73] Attempt to fix startup script --- docker/standalone/README.md | 7 +++-- docker/standalone/scripts/startup.sh | 38 +++++++++------------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/docker/standalone/README.md b/docker/standalone/README.md index 200234bf6..5a11a24c2 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -9,8 +9,9 @@ Once you have Docker installed, you can run CtrlPanel standalone Docker by execu Recommended way via Docker Compose: -Get the Compose file [here](https://github.com/Ctrlpanel-gg/panel/blob/docker-github-workflow/docker/standalone/compose.yaml). -This also includes all necessaries like a Database, Redis and optionally phpmyadmin to manage the Database. +1. Copy and configure your docker compose file to your needs `curl -L -o docker-compose.yml 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. Running as commandline command: @@ -18,8 +19,6 @@ Running as commandline command: docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html -v /path/to/nginx_config:/etc/nginx/conf.d/ ghcr.io/ctrlpanel-gg/panel:latest ``` -When installing you need to update the `.env` 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. - This command will run the latest CtrlPanel Docker image from Docker Hub and run it. The control panel will be available at http://localhost/install and will be a completely fresh installation. diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index e909ebcce..51e1eb328 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -25,35 +25,21 @@ log_message() { echo "$1" } -log_message "Contents of /var/default:" -ls -la /var/default - -log_message "Permissions of /var/www/html:" -ls -la /var/www/html - -chown -R laravel:laravel /var/www/html/ -chmod -R 777 /var/www/html/ -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/ +# The issue seems that "index.nginx-debian.html" seems to be in the folder, hence the next check will always fail. +rm /var/www/html/index.nginx-debian.html # Check if project folder is empty. -#if [ -z "$(ls -A /var/www/html)" ]; then -# chown -R laravel:laravel /var/www/html/ -# chmod -R 777 /var/www/html/ -# 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 - -log_message "Contents of /var/www/html:" -ls -la /var/www/html +if [ -z "$(ls -A /var/www/html)" ]; then + chown -R laravel:laravel /var/www/html/ + chmod -R 777 /var/www/html/ + 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) +# 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 From 1cb03f5e85255fc23ddd077ed02a04c3382fc790 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:34:21 +0200 Subject: [PATCH 60/73] Add logging to troubleshoot --- docker/standalone/scripts/startup.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 51e1eb328..5637a5e7e 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -25,9 +25,15 @@ log_message() { echo "$1" } +log_message "Permissions of /var/www/html:" +ls -la /var/www/html + # The issue seems that "index.nginx-debian.html" seems to be in the folder, hence the next check will always fail. rm /var/www/html/index.nginx-debian.html +log_message "Permissions of /var/www/html:" +ls -la /var/www/html + # Check if project folder is empty. if [ -z "$(ls -A /var/www/html)" ]; then chown -R laravel:laravel /var/www/html/ From 06a67fe8d2fc7582a5b33c64552e30f5568158c3 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:43:40 +0200 Subject: [PATCH 61/73] Check for public folder instead of if has contents --- docker/standalone/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 5637a5e7e..3811faea5 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -35,7 +35,7 @@ log_message "Permissions of /var/www/html:" ls -la /var/www/html # Check if project folder is empty. -if [ -z "$(ls -A /var/www/html)" ]; then +if [ ! -d "/var/www/html/public" ]; then chown -R laravel:laravel /var/www/html/ chmod -R 777 /var/www/html/ log_message "Warning: project folder is empty. Copying default files..." From 9188c42693fa7ea9cfcccb45ce148576a3ed2400 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:49:33 +0200 Subject: [PATCH 62/73] Remove unnecessary deletion of file --- docker/standalone/scripts/startup.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 3811faea5..664702eb2 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -25,16 +25,7 @@ log_message() { echo "$1" } -log_message "Permissions of /var/www/html:" -ls -la /var/www/html - -# The issue seems that "index.nginx-debian.html" seems to be in the folder, hence the next check will always fail. -rm /var/www/html/index.nginx-debian.html - -log_message "Permissions of /var/www/html:" -ls -la /var/www/html - -# Check if project folder is empty. +# Check if public folder is exists. If not, copy project. if [ ! -d "/var/www/html/public" ]; then chown -R laravel:laravel /var/www/html/ chmod -R 777 /var/www/html/ From ebe730bfef2aefc38f4695d7356e802d7e9f8702 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:52:50 +0200 Subject: [PATCH 63/73] Test if permissions are necessary --- docker/standalone/Dockerfile | 3 --- docker/standalone/README.md | 2 +- docker/standalone/scripts/startup.sh | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 474b7a98e..a16bed8cb 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -50,9 +50,6 @@ RUN mkdir -p /var/log/nginx && chown -R laravel:laravel /var/log/nginx # Expose ports EXPOSE 80 443 -# 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) -#COPY --chown=laravel:laravel /var/default/.env.example /var/www/html/.env - # Copy startup script COPY --chown=laravel:laravel ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh # Make startup script executable diff --git a/docker/standalone/README.md b/docker/standalone/README.md index 5a11a24c2..40c740a38 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -9,7 +9,7 @@ Once you have Docker installed, you can run CtrlPanel standalone Docker by execu Recommended way via Docker Compose: -1. Copy and configure your docker compose file to your needs `curl -L -o docker-compose.yml https://raw.githubusercontent.com/Ctrlpanel-gg/panel/blob/main/docker/standalone/compose.yaml`. +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. diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 664702eb2..233650626 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -27,8 +27,8 @@ log_message() { # Check if public folder is exists. If not, copy project. if [ ! -d "/var/www/html/public" ]; then - chown -R laravel:laravel /var/www/html/ - chmod -R 777 /var/www/html/ +# chown -R laravel:laravel /var/www/html/ +# chmod -R 777 /var/www/html/ 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 From 9e6688dd531b53da561ea8ab8e8026b5bb6b3380 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:56:16 +0200 Subject: [PATCH 64/73] Remove unnecessary permissions --- docker/standalone/scripts/startup.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/standalone/scripts/startup.sh b/docker/standalone/scripts/startup.sh index 233650626..bf11b5bff 100644 --- a/docker/standalone/scripts/startup.sh +++ b/docker/standalone/scripts/startup.sh @@ -27,8 +27,6 @@ log_message() { # Check if public folder is exists. If not, copy project. if [ ! -d "/var/www/html/public" ]; then -# chown -R laravel:laravel /var/www/html/ -# chmod -R 777 /var/www/html/ 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 From 44c05b0f6e2e56b2b95bc89baa24264be9ca3a1a Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:58:35 +0200 Subject: [PATCH 65/73] Update compose.yaml with only logs and env file --- docker/standalone/compose.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 6b00f27df..76e64b13b 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -9,10 +9,8 @@ services: - "80:80" - "443:443" volumes: -# - './env:/var/www/html/.env:rw' -# - './logs:/var/www/html/storage/logs:rw' - - './website_files:/var/www/html:rw' # change it -# - './nginx_config:/etc/nginx/conf.d/:rw' # change it + - './logs:/var/www/html/storage/logs:w' + - './env_file:/var/www/html/.env' networks: - controlpanel From 33096fbea4b156de3fbd6091ce29cca3018621f1 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 8 Jun 2024 08:36:41 +0200 Subject: [PATCH 66/73] Rename controlpanel to ctrlpanel --- docker/development/compose.yaml | 22 +++++++++++----------- docker/standalone/compose.yaml | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index 7f5acb0f8..fd1f09bab 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -1,10 +1,10 @@ services: # TODO: add wings and pterodactyl - controlpanel_panel: + ctrlpanel_panel: build: context: ../../ dockerfile: ./docker/standalone/Dockerfile - container_name: controlpanel_development + container_name: ctrlpanel_development restart: unless-stopped ports: - "80:80" @@ -13,11 +13,11 @@ services: - '../..:/var/www/html:rw' - './nginx_config:/etc/nginx/conf.d/:rw' networks: - - controlpanel + - ctrlpanel mysql: image: mysql - container_name: controlpanel_mysql + container_name: ctrlpanel_mysql restart: unless-stopped tty: true ports: @@ -30,31 +30,31 @@ services: volumes: - "./mysql:/var/lib/mysql:delegated" networks: - - controlpanel + - ctrlpanel phpmyadmin: image: phpmyadmin/phpmyadmin - container_name: controlpanel_phpmyadmin + container_name: ctrlpanel_phpmyadmin depends_on: - mysql ports: - '8080:80' environment: - - PMA_HOST=controlpanel_mysql + - PMA_HOST=ctrlpanel_mysql - PMA_USER=root - PMA_PASSWORD=root - PMA_ARBITRARY=1 networks: - - controlpanel + - ctrlpanel redis: image: redis - container_name: controlpanel_redis + container_name: ctrlpanel_redis restart: unless-stopped ports: - "6379:6379" networks: - - controlpanel + - ctrlpanel networks: - controlpanel: + ctrlpanel: diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 76e64b13b..496e6c0f8 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -1,7 +1,7 @@ services: - controlpanel: + ctrlpanel: image: ghcr.io/ctrlpanel-gg/panel:latest - container_name: controlpanel_panel + container_name: ctrlpanel_panel restart: unless-stopped depends_on: - redis @@ -12,11 +12,11 @@ services: - './logs:/var/www/html/storage/logs:w' - './env_file:/var/www/html/.env' networks: - - controlpanel + - ctrlpanel mysql: image: mysql - container_name: controlpanel_mysql + container_name: ctrlpanel_mysql restart: unless-stopped tty: true ports: @@ -29,32 +29,32 @@ services: volumes: - "./mysql:/var/lib/mysql:delegated" networks: - - controlpanel + - ctrlpanel phpmyadmin: image: phpmyadmin/phpmyadmin - container_name: controlpanel_phpmyadmin + container_name: ctrlpanel_phpmyadmin restart: unless-stopped depends_on: - mysql ports: - '8080:80' environment: - - PMA_HOST=controlpanel_mysql + - PMA_HOST=ctrlpanel_mysql - PMA_USER=root # change it - PMA_PASSWORD=root # change it - PMA_ARBITRARY=1 networks: - - controlpanel + - ctrlpanel redis: image: redis - container_name: controlpanel_redis + container_name: ctrlpanel_redis restart: unless-stopped ports: - "6379:6379" networks: - - controlpanel + - ctrlpanel networks: - controlpanel: + ctrlpanel: From 6a5f05e4192ddfdaef738e8dae05a52e9482e81f Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 8 Jun 2024 08:40:43 +0200 Subject: [PATCH 67/73] Fix typo --- themes/default/views/information/tos-content.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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
  9. From 05dc11ed6f608d01452db8f1d23df55188255acb Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:24:16 +0200 Subject: [PATCH 68/73] Update Readme and stanalone compose --- docker/standalone/README.md | 16 ++++++++-------- docker/standalone/compose.yaml | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docker/standalone/README.md b/docker/standalone/README.md index 40c740a38..2efaf6bfd 100644 --- a/docker/standalone/README.md +++ b/docker/standalone/README.md @@ -7,19 +7,19 @@ If you're using a different operating system, you can follow the official Docker Once you have Docker installed, you can run CtrlPanel standalone Docker by executing the following command: -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. - Running as commandline command: ```bash -docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html -v /path/to/nginx_config:/etc/nginx/conf.d/ ghcr.io/ctrlpanel-gg/panel:latest +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 Docker Hub and run it. +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. diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 496e6c0f8..0f29febae 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -11,6 +11,7 @@ services: volumes: - './logs:/var/www/html/storage/logs:w' - './env_file:/var/www/html/.env' + #- './website_files:/var/www/html:rw' # optionally use this, in case you want/need access to all project files, to use like addons/plugins. networks: - ctrlpanel From d210baa7d26caa591471ddca15de82722b93f092 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 8 Jun 2024 21:12:52 +0200 Subject: [PATCH 69/73] Docker compose default add project files --- docker/standalone/compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index 0f29febae..f9a3ac71e 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -11,7 +11,7 @@ services: volumes: - './logs:/var/www/html/storage/logs:w' - './env_file:/var/www/html/.env' - #- './website_files:/var/www/html:rw' # optionally use this, in case you want/need access to all project files, to use like addons/plugins. + - './website_files:/var/www/html:rw' # optionally use remove this bind mount, it's not needed unless you want access to all project files, to modify the project with addons/plugins. networks: - ctrlpanel From 01ca75fe4af8809e82e7f383c644e4cc9d19db98 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 8 Jun 2024 21:24:17 +0200 Subject: [PATCH 70/73] Fix typo --- docker/standalone/compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index f9a3ac71e..adb572b37 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -11,7 +11,7 @@ services: volumes: - './logs:/var/www/html/storage/logs:w' - './env_file:/var/www/html/.env' - - './website_files:/var/www/html:rw' # optionally use remove this bind mount, it's not needed unless you want access to all project files, to modify the project with addons/plugins. + - './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. networks: - ctrlpanel From a58aa10fffa298d465118266626ecd5d9389920b Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sat, 8 Jun 2024 22:41:55 +0200 Subject: [PATCH 71/73] Readd nginx config expose --- docker/standalone/compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index adb572b37..e1c2b7a61 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -12,6 +12,7 @@ services: - './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 From 628f2c6cb81f5d50493a751408c4ccb110b7cd0b Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 9 Jun 2024 16:48:30 +0200 Subject: [PATCH 72/73] Update dev docker service name --- docker/development/compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/development/compose.yaml b/docker/development/compose.yaml index fd1f09bab..1e8571a05 100644 --- a/docker/development/compose.yaml +++ b/docker/development/compose.yaml @@ -1,6 +1,6 @@ services: # TODO: add wings and pterodactyl - ctrlpanel_panel: + ctrlpanel_development: build: context: ../../ dockerfile: ./docker/standalone/Dockerfile From bb9bc296946513c73ac10047bbc30689529fcb95 Mon Sep 17 00:00:00 2001 From: jameskitt616 <52933658+jameskitt616@users.noreply.github.com> Date: Sun, 9 Jun 2024 16:51:04 +0200 Subject: [PATCH 73/73] Update standalone docker service name --- docker/standalone/compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/standalone/compose.yaml b/docker/standalone/compose.yaml index e1c2b7a61..b2d3ce2f4 100644 --- a/docker/standalone/compose.yaml +++ b/docker/standalone/compose.yaml @@ -1,7 +1,7 @@ services: - ctrlpanel: + ctrlpanel_standalone: image: ghcr.io/ctrlpanel-gg/panel:latest - container_name: ctrlpanel_panel + container_name: ctrlpanel_standalone restart: unless-stopped depends_on: - redis