From 4b60c03caa5ff990bf935b4b6ede7d8d32f0e8c5 Mon Sep 17 00:00:00 2001 From: Zero Date: Tue, 29 Oct 2024 23:06:50 +0800 Subject: [PATCH 1/3] re-write Dockerfile --- dev/docker/Dockerfile | 60 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 50d528faf..5040298e0 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -1,34 +1,34 @@ FROM php:8.3-apache +# Install additional dependencies +RUN apt-get update && \ + apt-get install -y \ + git \ + zip \ + unzip \ + libpng-dev \ + libldap2-dev \ + libzip-dev \ + wait-for-it && \ + rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN docker-php-ext-configure ldap --with-libdir="lib/$(gcc -dumpmachine)" && \ + docker-php-ext-install pdo_mysql gd ldap zip && \ + pecl install xdebug && \ + docker-php-ext-enable xdebug + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Configure apache +RUN a2enmod rewrite && \ + sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \ + sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +# Use the default production configuration and update it as required +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + sed -i 's/memory_limit = 128M/memory_limit = 512M/g' "$PHP_INI_DIR/php.ini" + ENV APACHE_DOCUMENT_ROOT /app/public WORKDIR /app - -RUN < Date: Tue, 29 Oct 2024 23:07:15 +0800 Subject: [PATCH 2/3] fix deprecated syntax --- dev/docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 5040298e0..9f283c755 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -30,5 +30,6 @@ RUN a2enmod rewrite && \ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ sed -i 's/memory_limit = 128M/memory_limit = 512M/g' "$PHP_INI_DIR/php.ini" -ENV APACHE_DOCUMENT_ROOT /app/public +ENV APACHE_DOCUMENT_ROOT="/app/public" + WORKDIR /app From 227c5e155b60ba9a442d23c64a9846366c3e15ac Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 1 Dec 2024 16:02:21 +0000 Subject: [PATCH 3/3] Dev Docker: Fixed missing gd jpeg handling, forced migrations Migrations run without force could fail startup in certain environment conditions (when testing production env). Also updated paths permission handling to update more needed locations. --- dev/docker/Dockerfile | 7 +++++-- dev/docker/entrypoint.app.sh | 4 ++-- dev/docs/development.md | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 9f283c755..edab90ca1 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -6,15 +6,18 @@ RUN apt-get update && \ git \ zip \ unzip \ - libpng-dev \ + libfreetype-dev \ + libjpeg62-turbo-dev \ libldap2-dev \ + libpng-dev \ libzip-dev \ wait-for-it && \ rm -rf /var/lib/apt/lists/* # Install PHP extensions RUN docker-php-ext-configure ldap --with-libdir="lib/$(gcc -dumpmachine)" && \ - docker-php-ext-install pdo_mysql gd ldap zip && \ + docker-php-ext-configure gd --with-freetype --with-jpeg && \ + docker-php-ext-install -j$(nproc) pdo_mysql gd ldap zip && \ pecl install xdebug && \ docker-php-ext-enable xdebug diff --git a/dev/docker/entrypoint.app.sh b/dev/docker/entrypoint.app.sh index e91d34a71..b09edda88 100755 --- a/dev/docker/entrypoint.app.sh +++ b/dev/docker/entrypoint.app.sh @@ -9,7 +9,7 @@ if [[ -n "$1" ]]; then else composer install wait-for-it db:3306 -t 45 - php artisan migrate --database=mysql - chown -R www-data:www-data storage + php artisan migrate --database=mysql --force + chown -R www-data storage public/uploads bootstrap/cache exec apache2-foreground fi diff --git a/dev/docs/development.md b/dev/docs/development.md index 3c7a6e9d2..0324140f8 100644 --- a/dev/docs/development.md +++ b/dev/docs/development.md @@ -82,7 +82,7 @@ If all the conditions are met, you can proceed with the following steps: 1. **Copy `.env.example` to `.env`**, change `APP_KEY` to a random 32 char string and set `APP_ENV` to `local`. 2. Make sure **port 8080 is unused** *or else* change `DEV_PORT` to a free port on your host. -3. **Run `chgrp -R docker storage`**. The development container will chown the `storage` directory to the `www-data` user inside the container so BookStack can write to it. You need to change the group to your host's `docker` group here to not lose access to the `storage` directory. +3. **Run `chgrp -R docker storage`**. The development container will chown the `storage`, `public/uploads` and `bootstrap/cache` directories to the `www-data` user inside the container so BookStack can write to it. You need to change the group to your host's `docker` group here to not lose access to the `storage` directory. 4. **Run `docker-compose up`** and wait until the image is built and all database migrations have been done. 5. You can now login with `admin@admin.com` and `password` as password on `localhost:8080` (or another port if specified).