From a0c3458c6d61ed29cdea86b31569dafaa1d06606 Mon Sep 17 00:00:00 2001 From: Fossil Date: Sat, 22 Jun 2024 19:50:52 +0100 Subject: [PATCH] Update Sail/Docker - Use Ubuntu 24.04 LTS - Laravel 11 Changes - Upgrade Node & Portgres versions - Use MariaDB Client by default - Python2 is not available in Ubuntu 24 by default - Brotli support. HTTPS only - Remove php-decimal - Install bun and pnpm alongside npm - Install correct 7-zip version based on AMD64/ARM64 arch - Add artisan bash alias --- docker-compose.yml.dist | 13 +++++---- docker/8.3/Dockerfile | 64 +++++++++++++++++++++++++---------------- docker/8.3/README.md | 8 ++++-- docker/8.3/nginx.conf | 47 ++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 33 deletions(-) diff --git a/docker-compose.yml.dist b/docker-compose.yml.dist index eb1b634dfb..0775f2ebbd 100644 --- a/docker-compose.yml.dist +++ b/docker-compose.yml.dist @@ -1,4 +1,3 @@ -version: '3' services: laravel.test: build: @@ -13,14 +12,16 @@ services: - '${APP_PORT:-80}:80' - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' environment: - TZ: ${APP_TZ} + TZ: ${APP_TIMEZONE} COMPOSER_AUTH: ${COMPOSER_AUTH} WWWUSER: '${WWWUSER}' LARAVEL_SAIL: 1 XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' + IGNITION_LOCAL_SITES_PATH: '${PWD}' volumes: - '.:/var/www/html' + - './docker/8.3/nginx.conf:/etc/nginx/sites-available/default' networks: - sail depends_on: @@ -33,7 +34,7 @@ services: ports: - '${FORWARD_DB_PORT:-3306}:3306' environment: - TZ: ${APP_TZ} + TZ: ${APP_TIMEZONE} MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' MYSQL_ROOT_HOST: '%' MYSQL_DATABASE: '${DB_DATABASE}' @@ -62,7 +63,7 @@ services: ports: - '${FORWARD_REDIS_PORT:-6379}:6379' environment: - TZ: ${APP_TZ} + TZ: ${APP_TIMEZONE} volumes: - 'sail-redis:/data' networks: @@ -84,7 +85,7 @@ services: manticore: image: manticoresearch/manticore environment: - TZ: ${APP_TZ} + TZ: ${APP_TIMEZONE} EXTRA: 1 # Activates extra features restart: always ports: @@ -106,7 +107,7 @@ services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2 environment: - - TZ=${APP_TZ} + - TZ=${APP_TIMEZONE} - discovery.type=single-node - xpack.security.enabled=false - "ES_JAVA_OPTS=-Xms512m -Xmx512m" diff --git a/docker/8.3/Dockerfile b/docker/8.3/Dockerfile index 37afb04243..76cee67989 100644 --- a/docker/8.3/Dockerfile +++ b/docker/8.3/Dockerfile @@ -1,52 +1,66 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.04 LABEL maintainer="Fossil01" ARG WWWGROUP -ARG NODE_VERSION=20 -ARG POSTGRES_VERSION=15 +ARG NODE_VERSION=21 +ARG POSTGRES_VERSION=16 +ARG SEVENZIP_VERSION=2407 +ARG MYSQL_CLIENT="mariadb-client" WORKDIR /var/www/html ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip unrar git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip unrar 7zip lame git supervisor sqlite3 libcap2-bin libpng-dev python3 dnsutils \ && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \ - && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ + && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ + && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/nginx/ubuntu noble main" > /etc/apt/sources.list.d/ppa_ondrej_nginx.list \ && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null \ && echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null \ - && echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ + && echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && apt-get update \ - && apt-get install -y php8.3-cli php8.3-dev \ - php8.3-pgsql php8.3-sqlite3 php8.3-gd php8.3-imagick \ - php8.3-curl \ - php8.3-imap php8.3-mysql php8.3-mbstring \ - php8.3-xml php8.3-zip php8.3-bcmath php8.3-soap \ - php8.3-intl php8.3-readline \ - php8.3-ldap \ - php8.3-msgpack php8.3-igbinary php8.3-redis php8.3-swoole \ - php8.3-memcached php8.3-pcov php8.3-xdebug \ - tmux iputils-ping net-tools libmediainfo0v5 mediainfo libzen0v5 ffmpeg \ - sudo jq htop fonts-powerline nano bash-completion time wget cron \ - nginx php8.3-fpm \ - jpegoptim webp optipng pngquant libavif-bin \ + && apt-get install -y php8.3 php8.3-cli php8.3-common php8.3-mysql php8.3-xdebug php8.3-dev \ + php8.3-amqp php8.3-bcmath php8.3-bz2 php8.3-curl php8.3-gd php8.3-gmp php8.3-gnupg \ + php8.3-http php8.3-igbinary php8.3-imagick php8.3-intl php8.3-mbstring php8.3-msgpack \ + php8.3-oauth php8.3-opcache php8.3-raphf php8.3-readline php8.3-redis php8.3-soap php8.3-sqlite3 \ + php8.3-swoole php8.3-tidy php8.3-uploadprogress php8.3-uuid php8.3-xml php8.3-xmlrpc php8.3-xsl \ + php8.3-yaml php8.3-zip php8.3-zstd php8.3-pgsql php8.3-sockets php8.3-imap php8.3-ldap php8.3-memcached php8.3-pcov \ + tmux iputils-ping net-tools ffmpeg \ + sudo jq htop fonts-powerline nano bash-completion time wget cron \ + nginx php8.3-fpm libnginx-mod-brotli \ + jpegoptim webp optipng pngquant libavif-bin \ + && wget https://mediaarea.net/repo/deb/repo-mediaarea_1.0-24_all.deb \ + && dpkg -i repo-mediaarea_1.0-24_all.deb \ + && apt-get update \ + && apt-get install -y libmediainfo0v5 mediainfo libzen0v5 \ && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ && apt-get install -y nodejs \ - && npm install -g npm \ - && apt-get install -y yarn \ - && apt-get install -y mysql-client \ - && apt-get install -y postgresql-client-$POSTGRES_VERSION \ + && npm install -g npm bun pnpm \ + && apt-get install -y yarn $MYSQL_CLIENT postgresql-client-$POSTGRES_VERSION \ && apt-get -y autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.3 +# Determine ARCH and download and extract the appropriate version of 7-Zip +RUN ARCH="$(dpkg --print-architecture)" && \ + if [ "$ARCH" = "amd64" ]; then \ + SZIP_URL="https://www.7-zip.org/a/7z$SEVENZIP_VERSION-linux-x64.tar.xz"; \ + fi && \ + if [ "$ARCH" = "arm64" ]; then \ + SZIP_URL="https://www.7-zip.org/a/7z2407-linux-arm64.tar.xz"; \ + fi && \ + wget "$SZIP_URL" -O /tmp/7z.tar.xz && \ + tar -xf /tmp/7z.tar.xz -C /tmp/ && \ + mv /tmp/7zz /usr/bin/7zz && \ + rm -f /tmp/7z.tar.xz && rm -f /tmp/7zzs RUN groupadd --force -g $WWWGROUP sail RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail +RUN echo "alias artisan=\"php artisan\"" >> /home/sail/.bashrc COPY scheduler /etc/cron.d/scheduler RUN chmod 0644 /etc/cron.d/scheduler \ @@ -62,4 +76,4 @@ RUN chmod +x /usr/local/bin/start-container EXPOSE 80 #ENTRYPOINT ["tail", "-f", "/dev/null"] # Use only for debugging -ENTRYPOINT ["start-container"] +ENTRYPOINT ["start-container"] \ No newline at end of file diff --git a/docker/8.3/README.md b/docker/8.3/README.md index fe10065278..d08d3d0c21 100644 --- a/docker/8.3/README.md +++ b/docker/8.3/README.md @@ -2,7 +2,11 @@ **Author:** [Fossil01](https://github.com/Fossil01) -The development environment contains the: App, MariaDB, Redis, Manticore and Mailpit containers. The app container is where nginx and PHP-FPM run and has a bind mount to the root directory of this project. Supervisord is used to run it all in the background. Manticore can be switched out for Elasticsearch by commenting/uncommenting the corresponding lines in `docker-compose.yml`. Elasticsearch has security disabled by default. +### Caution: This setup is intended solely for development use. For production deployments, it is recommended to construct your own Docker containers. + +This development environment is composed of several key containers: App, MariaDB, Redis, Manticore, and Mailpit. The App container hosts nginx and PHP-FPM, and includes a bind mount that links to the root directory of this project. Supervisord is utilized to manage these services in the background. + +For search capabilities, Manticore is the default setup, but you can easily switch to Elasticsearch by modifying the corresponding lines in the docker-compose.yml file. Note that Elasticsearch is configured with security features disabled by default. This container also houses several tools to run the indexing backend: tmux, ffmpeg, mediainfo, unrar etc. It also has MariaDB & Postgres clients, NodeJS & Yarn. @@ -10,7 +14,7 @@ nginx runs on port 80 and is mapped to port 80 on the host machine too. If you'r Mailpit is used as a fake mailserver which catches all e-mails in one inbox. You can acess this via [this link](http://localhost:8025). Mailpit's SMTP server runs on port `1025`. ->This project currently uses PHP 8.3 and MariaDB 10.x +> This project currently uses PHP 8.3 and MariaDB 11.x ## Prerequisites diff --git a/docker/8.3/nginx.conf b/docker/8.3/nginx.conf index e69de29bb2..eb7e7a76c9 100644 --- a/docker/8.3/nginx.conf +++ b/docker/8.3/nginx.conf @@ -0,0 +1,47 @@ +server { + listen 80; + root "/var/www/html/public"; + index index.html index.htm index.php; + charset utf-8; + + gzip on; + gzip_types text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/xml application/xml+rss application/atom+xml image/x-icon font/opentype application/json; + gzip_min_length 256; + gzip_vary on; + gzip_disable "MSIE [1-6]\.(?!.*SV1)"; + gzip_proxied any; + + brotli on; + brotli_comp_level 6; + brotli_static on; + brotli_types application/atom+xml application/javascript application/json application/rss+xml + application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype + application/x-font-ttf application/x-javascript application/xhtml+xml application/xml + font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon + image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + location ^~ /covers/ { + root /var/www/html/storage; + } + + access_log /dev/stdout; + error_log stderr error; + + sendfile off; + + client_max_body_size 100m; + + location ~ \.php$ { + include /etc/nginx/fastcgi_params; + fastcgi_pass unix:/run/php/php8.3-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ /\.ht { + deny all; + } +} \ No newline at end of file