From a3e1821ca0da60d602af88fb5d33c6fe35ed8f6f Mon Sep 17 00:00:00 2001 From: Jens Kat Date: Sat, 9 Sep 2017 12:46:35 +0200 Subject: [PATCH 1/2] Docker: Use working directory instead of hardcoded dist version - By using the current (.) working directory, we can get the latest changes in the Docker image. If the building of Docker images is automated, it will automatically pick up the checked out version. - Rearrange some Docker layers things that don't invalidate that much. --- .dockerignore | 4 ++++ .gitignore | 5 ++++- Dockerfile | 20 ++++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..f42d602ac3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +# Ignore composer specific files and vendor folder +composer.phar +composer.lock +vendor diff --git a/.gitignore b/.gitignore index d4cfc0d4fb..d7d1a372b1 100755 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ /node_modules /public/storage -/vendor Homestead.json Homestead.yaml .env public/google*.html report.html + +### Composer ### +composer.phar +/vendor/ diff --git a/Dockerfile b/Dockerfile index 792f7b2c8d..bcc5fc9079 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,18 +23,26 @@ RUN docker-php-ext-install -j$(nproc) curl gd intl json mcrypt readline tidy zip # Generate locales supported by firefly 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 docker/apache2.conf /etc/apache2/apache2.conf +COPY ./docker/apache2.conf /etc/apache2/apache2.conf + # Enable apache mod rewrite.. RUN a2enmod rewrite # Setup the Composer installer -run curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -RUN cd /var/www && composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist firefly-iii 4.6.4 -COPY docker/entrypoint.sh /var/www/firefly-iii/docker/entrypoint.sh -ADD docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf -RUN chown -R www-data:www-data /var/www && chmod -R 775 /var/www/firefly-iii/storage +# Copy Apache Configs +COPY ./docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf WORKDIR /var/www/firefly-iii + +# The working directory +COPY . /var/www/firefly-iii/ + +RUN chown -R www-data:www-data /var/www && chmod -R 775 /var/www/firefly-iii/storage + +RUN composer install --prefer-dist --no-dev --no-scripts + EXPOSE 80 + ENTRYPOINT ["/var/www/firefly-iii/docker/entrypoint.sh"] From 2bf47f6d58455ad88dda5d7e49d22633a39ae7b8 Mon Sep 17 00:00:00 2001 From: Jens Kat Date: Sat, 9 Sep 2017 13:17:01 +0200 Subject: [PATCH 2/2] Use environment variable for install dir --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index bcc5fc9079..1d150bcdf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,15 +34,17 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local # Copy Apache Configs COPY ./docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf -WORKDIR /var/www/firefly-iii +ENV FIREFLY_PATH /var/www/firefly-iii + +WORKDIR $FIREFLY_PATH # The working directory -COPY . /var/www/firefly-iii/ +COPY . $FIREFLY_PATH -RUN chown -R www-data:www-data /var/www && chmod -R 775 /var/www/firefly-iii/storage +RUN chown -R www-data:www-data /var/www && chmod -R 775 $FIREFLY_PATH/storage RUN composer install --prefer-dist --no-dev --no-scripts EXPOSE 80 -ENTRYPOINT ["/var/www/firefly-iii/docker/entrypoint.sh"] +ENTRYPOINT ["docker/entrypoint.sh"]