Complete dockerfile and associated scripts

This commit is contained in:
Julien Stebenne 2020-07-03 00:36:55 -04:00
parent 9f93f06c66
commit 8d1c4e890b
3 changed files with 34 additions and 49 deletions

View File

@ -1,77 +1,44 @@
FROM php:7.3-apache
# Install composer from official image
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Enable Apache Rewrite + Expires Module
RUN a2enmod rewrite expires
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libyaml-dev \
libzip4 \
libzip-dev \
zlib1g-dev \
libicu-dev \
g++ \
git \
cron \
vim \
curl \
unzip \
gnupg2 \
&& docker-php-ext-install opcache \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
unzip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install zip \
&& rm -rf /var/lib/apt/lists/*
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
echo 'upload_max_filesize=128M'; \
echo 'post_max_size=128M'; \
} > /usr/local/etc/php/conf.d/php-recommended.ini
RUN pecl install apcu \
&& pecl install yaml-2.0.4 \
&& docker-php-ext-enable apcu yaml
RUN curl -s https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get -y install yarn && \
rm -rf /var/lib/apt/lists/*
# Set user to www-data
# RUN chown www-data:www-data /var/www
USER www-data
RUN { \
echo 'upload_max_filesize=128M'; \
echo 'post_max_size=128M'; \
} > /usr/local/etc/php/conf.d/php-recommended.ini
# Copy files
COPY ./ /var/www/html
# COPY --chown=www-data:www-data ./ /var/www/html
# Return to root user
USER root
RUN chown -R www-data:www-data /var/www
RUN chmod -R 777 /var/www
# USER www-data
# WORKDIR /var/www/html
# RUN composer install && \
# yarn install
USER www-data
WORKDIR /var/www/html
RUN composer install && \
yarn install
USER root
# USER root
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
ENTRYPOINT [ "/var/www/html/entrypoint.sh" ]

13
entrypoint.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
APACHE_DOCUMENT_ROOT="/var/www/html/public"
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
composer install
yarn install
usermod -u $DATA_UID www-data
groupmod -g $DATA_UID www-data
exec ${@:-apache2-foreground}

5
start-dev.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
docker build -t grocy:dev -f ./Dockerfile.dev .
docker run -p 8000:80 -v $DIR:/var/www/html -e DATA_UID=$UID grocy:dev