Update Docker config for Ubuntu 22.04

This commit is contained in:
Alex Cabal 2023-12-09 11:14:40 -06:00
parent bb07a19147
commit fa312ea089
3 changed files with 26 additions and 13 deletions

View file

@ -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 its a self-signed certificate youll need to accept whatever browser security warnings come up.

View file

@ -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"]

View file

@ -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