From fa312ea089ec2570b508c68aab26f63acbb10a7b Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Sat, 9 Dec 2023 11:14:40 -0600 Subject: [PATCH] Update Docker config for Ubuntu 22.04 --- README.md | 6 +++--- vms/docker/Dockerfile | 20 +++++++++++++------- vms/docker/start-server.sh | 13 ++++++++++--- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 557930e2..8ed322a1 100644 --- a/README.md +++ b/README.md @@ -57,16 +57,16 @@ If everything went well, `https://standardebooks.test/ebooks` will show the one ## Installation using Docker -We provide a Dockerfile for testing code changes. You can build an image with: +We provide a Dockerfile for testing code changes. You can create a container with: ```shell -docker build . -t standardebooks -f vms/docker/Dockerfile +docker build . --tag standardebooks --file vms/docker/Dockerfile ``` Then run the built image with: ```shell -docker run -dp 443:443 -v "$(pwd):/standardebooks.org/web" standardebooks:latest +docker run --detach --publish 443:443 --volume "$(pwd):/standardebooks.org/web" standardebooks:latest ``` The site will now be available at `https://localhost/`, although as it’s a self-signed certificate you’ll need to accept whatever browser security warnings come up. diff --git a/vms/docker/Dockerfile b/vms/docker/Dockerfile index 92411643..4606485e 100644 --- a/vms/docker/Dockerfile +++ b/vms/docker/Dockerfile @@ -1,23 +1,29 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y composer php-fpm php-cli php-gd php-xml php-apcu php-mbstring php-intl php-curl php-zip apache2 apache2-utils libfcgi0ldbl task-spooler libaprutil1-dbd-mysql attr libapache2-mod-xsendfile -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y sudo imagemagick openjdk-8-jre python3 pip calibre -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# Install required packages +RUN apt update +RUN DEBIAN_FRONTEND=noninteractive apt install -y composer php-fpm php-cli php-gd php-xml php-apcu php-mbstring php-intl php-curl php-zip apache2 apache2-utils libfcgi0ldbl task-spooler libaprutil1-dbd-mysql attr libapache2-mod-xsendfile sudo imagemagick openjdk-8-jre python3 pip calibre +# Install Python package for standardebooks RUN pip install standardebooks +# Create group and user for standardebooks RUN sudo addgroup committers RUN sudo adduser se RUN sudo usermod -g committers se +# Create necessary directories RUN mkdir -p /standardebooks.org/web RUN mkdir /var/log/local +# Enable Apache modules RUN a2enmod headers expires ssl rewrite proxy proxy_fcgi authn_dbd authn_socache -# Disable opcaching for dynamic PHP reloading -RUN echo "opcache.enable=0" >> /etc/php/7.4/fpm/php.ini +# Disable opcode caching to enable dynamic PHP reloading +RUN echo "opcache.enable=0" >> /etc/php/*/fpm/php.ini +# Expose port for https EXPOSE 443 + +# Set entrypoint ENTRYPOINT ["/standardebooks.org/web/vms/docker/start-server.sh"] diff --git a/vms/docker/start-server.sh b/vms/docker/start-server.sh index 5336a400..add6c8df 100755 --- a/vms/docker/start-server.sh +++ b/vms/docker/start-server.sh @@ -1,18 +1,25 @@ #!/bin/sh +# Generate SSL certificate if it doesn't exist if [ ! -f /standardebooks.org/web/config/ssl/standardebooks.test.crt ]; then openssl req -x509 -nodes -days 99999 -newkey rsa:4096 -subj "/CN=standardebooks.test" -keyout /standardebooks.org/web/config/ssl/standardebooks.test.key -sha256 -out /standardebooks.org/web/config/ssl/standardebooks.test.crt fi +# Install PHP dependencies cd /standardebooks.org/web composer install +# Create symlinks for web server configuration ln -s /standardebooks.org/web/config/apache/standardebooks.test.conf /etc/apache2/sites-available/ -ln -s /standardebooks.org/web/config/php/fpm/standardebooks.org.ini /etc/php/*/cli/conf.d/ -ln -s /standardebooks.org/web/config/php/fpm/standardebooks.org.ini /etc/php/*/fpm/conf.d/ +ln -s /standardebooks.org/web/config/php/fpm/standardebooks.test.ini /etc/php/*/cli/conf.d/ +ln -s /standardebooks.org/web/config/php/fpm/standardebooks.test.ini /etc/php/*/fpm/conf.d/ ln -s /standardebooks.org/web/config/php/fpm/standardebooks.test.conf /etc/php/*/fpm/pool.d/ + +# Enable web server configuration a2ensite standardebooks.test -service apache2 start + +# Restart services to load new configuration +service apache2 restart service php7.4-fpm restart # Keep the server available by holding open the container