Add entrypoint to unzip to unzip source, and change Dockerfile source location.

This commit is contained in:
Romain FLUTTAZ 2018-10-25 22:58:14 +02:00
parent b6bd348392
commit 5f5576eccb
No known key found for this signature in database
GPG Key ID: 77742BF14255988E
3 changed files with 72 additions and 41 deletions

View File

@ -1,4 +1,6 @@
FROM php:7.2-apache
ARG PHP_VERSION=7.2
FROM php:${PHP_VERSION}-apache
LABEL maintainer="Andy Miller <rhuk@getgrav.org> (@rhukster)" \
maintainer="Romain Fluttaz <romain@fluttaz.fr>"
@ -16,7 +18,6 @@ RUN set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
@ -54,36 +55,40 @@ RUN { \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
RUN { \
echo 'upload_max_filesize = 128M'; \
echo 'post_max_size = 128M'; \
} > /usr/local/etc/php/conf.d/php-recommended.ini
echo 'max_execution_time = 600'; \
echo 'max_input_vars = 5000'; \
} > /usr/local/etc/php/conf.d/php-optimisations.ini
# Enable Apache Rewrite + Expires Module
RUN a2enmod rewrite expires
# VOLUME /var/www/html
VOLUME /var/www/html
# Set user to www-data
RUN chown www-data:www-data /var/www
USER www-data
RUN chown -R www-data:www-data /var/www
# Define Grav version and expected SHA1 signature
ENV GRAV_VERSION 1.5.1
ENV GRAV_SHA1 5292b05d304329beefeddffbf9f542916012c221
# Install grav
WORKDIR /var/www
RUN curl -o grav-admin.zip -SL https://getgrav.org/download/core/grav-admin/${GRAV_VERSION} && \
echo "$GRAV_SHA1 grav-admin.zip" | sha1sum -c - && \
unzip grav-admin.zip && \
mv -T /var/www/grav-admin /var/www/html && \
rm grav-admin.zip
RUN set -ex; \
curl -o grav-admin.zip -fSL https://getgrav.org/download/core/grav-admin/${GRAV_VERSION}; \
echo "$GRAV_SHA1 grav-admin.zip" | sha1sum -c -; \
# upstream tarballs include ./grav-admin/ so this gives us /usr/src/grav-admin
unzip grav-admin.zip -d /usr/src/; \
rm grav-admin.zip; \
chown -R www-data:www-data /usr/src/grav-admin
# Return to root user
USER root
# Copy init scripts
# COPY docker-entrypoint.sh /entrypoint.sh
COPY entrypoint.sh /usr/local/bin/
# ENTRYPOINT ["/entrypoint.sh"]
# CMD ["apache2-foreground"]
ENTRYPOINT ["entrypoint.sh"]
CMD ["apache2-foreground"]"]

View File

@ -1,6 +1,8 @@
# Official Docker Image for Grav
# Docker Image for Grav
This currently is pretty minimal and uses:
_[Based on official grav docker image](https://github.com/getgrav/docker-grav)_
Fonctionnalities :
* apache-2.4.8
* GD library
@ -9,6 +11,7 @@ This currently is pretty minimal and uses:
* php7.2-opcache
* php7.2-acpu
* php7.2-yaml
* php7.2-ldap
## Building the image from Dockerfile
@ -24,18 +27,4 @@ docker run -p 8000:80 grav:latest
Point browser to `http://localhost/8000` and create user account...
## Running local Grav installation
This assumes you have already downloaded a Grav package into a local folder. This is the best way to run Grav if you want to have your changes persisted between restarts of the docker container.
```
docker run -v /local/grav/install:/var/www/html:cached -p 8000:80/tcp grav:latest
```
To run in the current directory you can use:
```
docker run -v `pwd`:/var/www/html:cached -p 8000:80/tcp grav:latest
```
Point browser to `http://localhost/8000` to access your Grav site

37
entrypoint.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -euo pipefail
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
group="${APACHE_RUN_GROUP:-www-data}"
;;
*) # php-fpm
user='www-data'
group='www-data'
;;
esac
else
user="$(id -u)"
group="$(id -g)"
fi
if [ ! -e index.php ]; then
echo >&2 "Grav not found in $PWD - copying now..."
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
fi
tar --create \
--file - \
--one-file-system \
--directory /usr/src/grav-admin \
--owner "$user" --group "$group" \
. | tar --extract --file -
echo >&2 "Complete! Grav has been successfully copied to $PWD"
fi
fi
exec "$@"