Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile to support PHP 8 #1272

Open
wants to merge 2 commits into
base: skosmos-2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 22 additions & 29 deletions dockerfiles/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
FROM ubuntu:20.04
FROM php:8.1-apache-buster

LABEL maintainer="National Library of Finland"
LABEL version="0.1"
LABEL version="0.2"
LABEL description="A Docker image for Skosmos with Apache httpd."

ARG DEBIAN_FRONTEND=noninteractive
# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# timezone
RUN sed -i 's/;date.timezone =/date.timezone = "UTC"/g' "$PHP_INI_DIR/php.ini"

# git is necessary for some composer packages e.g. davidstutz/bootstrap-multiselect
# gettext is necessary as php-gettext was available in 18.04, but not in 20.04
RUN apt-get update && apt-get install -y \
apache2 \
curl \
gettext \
git \
libapache2-mod-php7.4 \
libicu-dev \
libxslt-dev \
libzip-dev \
locales \
php7.4 \
php7.4-curl \
php7.4-xsl \
php7.4-intl \
php7.4-mbstring \
php-apcu \
php-zip \
unzip \
&& rm -rf /var/lib/apt/lists/*

# apcu was dropped in php 8, but can still be used if you install it via pecl, for instance
RUN pecl install apcu && \
pecl install zip && \
docker-php-ext-install gettext && \
docker-php-ext-install intl && \
docker-php-ext-install xsl && \
docker-php-ext-enable apcu && \
docker-php-ext-enable zip

# https://stackoverflow.com/a/28406007
# fixes warnings like perl: warning: Setting locale failed.
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
Expand Down Expand Up @@ -52,32 +57,20 @@ ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8

# timezone
RUN sed -i 's/;date.timezone =/date.timezone = "UTC"/g' /etc/php/7.4/apache2/php.ini

COPY dockerfiles/config/000-default.conf /etc/apache2/sites-available/000-default.conf

RUN a2enmod rewrite
RUN a2enmod expires

# set ServerName & redirect error log to stderr for docker logs
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
sed -ri \
-e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/1!g' \
"/etc/apache2/apache2.conf"

WORKDIR /var/www/html
RUN rm index.html

# composer and packages layer
RUN curl -sS https://getcomposer.org/installer | php
COPY composer.json /var/www/html
RUN php composer.phar install --no-dev --no-autoloader
# RUN curl -sS https://getcomposer.org/installer | php
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# skosmos layer
COPY . /var/www/html
RUN php composer.phar install --no-dev

COPY . /var/www/html/
RUN composer install --no-dev

# Configure Skosmos
COPY dockerfiles/config/config-docker.ttl /var/www/html/config.ttl
Expand Down