mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 13:26:14 +02:00
Complete dockerfile and associated scripts
This commit is contained in:
parent
9f93f06c66
commit
8d1c4e890b
|
|
@ -1,77 +1,44 @@
|
||||||
FROM php:7.3-apache
|
FROM php:7.3-apache
|
||||||
|
|
||||||
|
# Install composer from official image
|
||||||
|
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
# Enable Apache Rewrite + Expires Module
|
# Enable Apache Rewrite + Expires Module
|
||||||
RUN a2enmod rewrite expires
|
RUN a2enmod rewrite expires
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
unzip \
|
|
||||||
libfreetype6-dev \
|
libfreetype6-dev \
|
||||||
libjpeg62-turbo-dev \
|
libjpeg62-turbo-dev \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
libyaml-dev \
|
libyaml-dev \
|
||||||
libzip4 \
|
|
||||||
libzip-dev \
|
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
libicu-dev \
|
|
||||||
g++ \
|
|
||||||
git \
|
git \
|
||||||
cron \
|
|
||||||
vim \
|
|
||||||
curl \
|
curl \
|
||||||
unzip \
|
|
||||||
gnupg2 \
|
gnupg2 \
|
||||||
&& docker-php-ext-install opcache \
|
unzip \
|
||||||
&& docker-php-ext-configure intl \
|
|
||||||
&& docker-php-ext-install intl \
|
|
||||||
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
|
&& 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 -j$(nproc) gd \
|
||||||
&& docker-php-ext-install zip \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& 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 - && \
|
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 && \
|
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 && \
|
apt-get update && apt-get -y install yarn && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set user to www-data
|
RUN { \
|
||||||
# RUN chown www-data:www-data /var/www
|
echo 'upload_max_filesize=128M'; \
|
||||||
USER www-data
|
echo 'post_max_size=128M'; \
|
||||||
|
} > /usr/local/etc/php/conf.d/php-recommended.ini
|
||||||
|
|
||||||
# Copy files
|
# COPY --chown=www-data:www-data ./ /var/www/html
|
||||||
COPY ./ /var/www/html
|
|
||||||
|
|
||||||
# Return to root user
|
# USER www-data
|
||||||
USER root
|
# WORKDIR /var/www/html
|
||||||
RUN chown -R www-data:www-data /var/www
|
# RUN composer install && \
|
||||||
RUN chmod -R 777 /var/www
|
# yarn install
|
||||||
|
|
||||||
USER www-data
|
# USER root
|
||||||
WORKDIR /var/www/html
|
|
||||||
RUN composer install && \
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
USER root
|
|
||||||
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
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
13
entrypoint.sh
Executable 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
5
start-dev.sh
Executable 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
|
||||||
Loading…
Reference in New Issue
Block a user