Merge branch 'docker-simplify' into development

This commit is contained in:
Dan Brown 2024-12-01 16:10:22 +00:00
commit 3298374113
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
3 changed files with 33 additions and 29 deletions

View File

@ -1,34 +1,38 @@
FROM php:8.3-apache FROM php:8.3-apache
ENV APACHE_DOCUMENT_ROOT /app/public
WORKDIR /app
RUN <<EOR
# Install additional dependencies # Install additional dependencies
apt-get update RUN apt-get update && \
apt-get install -y \ apt-get install -y \
git \ git \
zip \ zip \
unzip \ unzip \
libpng-dev \ libfreetype-dev \
libldap2-dev \ libjpeg62-turbo-dev \
libzip-dev \ libldap2-dev \
wait-for-it libpng-dev \
rm -rf /var/lib/apt/lists/* libzip-dev \
wait-for-it && \
rm -rf /var/lib/apt/lists/*
# Configure apache # Install PHP extensions
docker-php-ext-configure ldap --with-libdir="lib/$(gcc -dumpmachine)" 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 && \
pecl install xdebug docker-php-ext-install -j$(nproc) pdo_mysql gd ldap zip && \
docker-php-ext-enable xdebug pecl install xdebug && \
a2enmod rewrite docker-php-ext-enable xdebug
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
# Install composer # Install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=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 # Use the default production configuration and update it as required
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" 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" sed -i 's/memory_limit = 128M/memory_limit = 512M/g' "$PHP_INI_DIR/php.ini"
EOR
ENV APACHE_DOCUMENT_ROOT="/app/public"
WORKDIR /app

View File

@ -9,7 +9,7 @@ if [[ -n "$1" ]]; then
else else
composer install composer install
wait-for-it db:3306 -t 45 wait-for-it db:3306 -t 45
php artisan migrate --database=mysql php artisan migrate --database=mysql --force
chown -R www-data:www-data storage chown -R www-data storage public/uploads bootstrap/cache
exec apache2-foreground exec apache2-foreground
fi fi

View File

@ -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`. 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. 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. 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). 5. You can now login with `admin@admin.com` and `password` as password on `localhost:8080` (or another port if specified).