diff --git a/Dockerfile.dev b/Dockerfile.dev index d32e3bf9..ba15fc3c 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -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 \ No newline at end of file + +ENTRYPOINT [ "/var/www/html/entrypoint.sh" ] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..24d62681 --- /dev/null +++ b/entrypoint.sh @@ -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} \ No newline at end of file diff --git a/start-dev.sh b/start-dev.sh new file mode 100755 index 00000000..ef8f0ecc --- /dev/null +++ b/start-dev.sh @@ -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 \ No newline at end of file