From 54ecfac550d782121d18264cca5d19fa0f044314 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 15 Dec 2017 09:16:41 +0100 Subject: [PATCH] New docker related files. --- Dockerfile | 35 ++++++++++++++++++++++------------- docker/docker.env | 6 ++++++ docker/entrypoint.sh | 3 +++ 3 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 docker/docker.env diff --git a/Dockerfile b/Dockerfile index 6dcd9cdc2d..9177d3a136 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,12 @@ +# use PHP 7.1 and Apache as a base. FROM php:7.1-apache +# set working dir +ENV FIREFLY_PATH /var/www/firefly-iii +WORKDIR $FIREFLY_PATH +ADD . $FIREFLY_PATH + +# install packages RUN apt-get update -y && \ apt-get install -y --no-install-recommends libcurl4-openssl-dev \ zlib1g-dev \ @@ -14,14 +21,16 @@ RUN apt-get update -y && \ libbz2-dev \ gettext-base \ locales && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +# Install PHP exentions. RUN docker-php-ext-install -j$(nproc) curl gd intl json readline tidy zip bcmath xml mbstring pdo_sqlite pdo_mysql bz2 pdo_pgsql -# Generate locales supported by firefly +# Generate locales supported by Firefly III RUN echo "en_US.UTF-8 UTF-8\nde_DE.UTF-8 UTF-8\nnl_NL.UTF-8 UTF-8\npt_BR.UTF-8 UTF-8" > /etc/locale.gen && locale-gen +# copy Apache config to correct spot. COPY ./docker/apache2.conf /etc/apache2/apache2.conf # Enable apache mod rewrite.. @@ -30,23 +39,23 @@ RUN a2enmod rewrite # Enable apache mod ssl.. RUN a2enmod ssl +# Create volumes for several directories: +VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload + # Setup the Composer installer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -# Copy Apache Configs +# Enable default site (Firefly III) COPY ./docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf -ENV FIREFLY_PATH /var/www/firefly-iii - -WORKDIR $FIREFLY_PATH - -# The working directory -COPY . $FIREFLY_PATH - +# Make sure we own Firefly III directory RUN chown -R www-data:www-data /var/www && chmod -R 775 $FIREFLY_PATH/storage -RUN composer install --prefer-dist --no-dev --no-scripts +# Run composer +RUN composer install --prefer-dist --no-dev --no-scripts --no-suggest +# Expose port 80 EXPOSE 80 -ENTRYPOINT ["docker/entrypoint.sh"] +# Run entrypoint thing +ENTRYPOINT ["docker/entrypoint.sh"] \ No newline at end of file diff --git a/docker/docker.env b/docker/docker.env new file mode 100644 index 0000000000..7ba55b06fe --- /dev/null +++ b/docker/docker.env @@ -0,0 +1,6 @@ +FF_APP_ENV=local +FF_APP_KEY=S0m3R@nd0mString0f32Ch@rsEx@ct1y +FF_DB_HOST= +FF_DB_NAME= +FF_DB_USER= +FF_DB_PASSWORD= \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 5f6409bf3b..088a999742 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,5 +1,8 @@ #!/bin/bash +# make sure we own the volumes: +chown -R www-data:www-data $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload +chmod -R 775 $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload cat .env.docker | envsubst > .env && cat .env composer dump-autoload