Merge a36ce85019 into c8b5d72dad
This commit is contained in:
commit
de38cbe0be
|
|
@ -0,0 +1,40 @@
|
|||
image: docker:latest
|
||||
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
|
||||
build-master:
|
||||
stage: build
|
||||
script:
|
||||
- docker pull "$CI_REGISTRY_IMAGE:latest" || true
|
||||
- docker build --cache-from "$CI_REGISTRY_IMAGE:latest" --pull -t "$CI_REGISTRY_IMAGE:latest" .
|
||||
- docker push "$CI_REGISTRY_IMAGE:latest"
|
||||
only:
|
||||
- master
|
||||
- schedules
|
||||
|
||||
build-master-tag:
|
||||
stage: build
|
||||
script:
|
||||
- docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||
only:
|
||||
- tags
|
||||
- schedules
|
||||
- master
|
||||
except:
|
||||
- branches
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" || true
|
||||
- docker build --cache-from "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
|
||||
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
||||
except:
|
||||
- master
|
||||
only:
|
||||
- branches
|
||||
96
Dockerfile
96
Dockerfile
|
|
@ -1,20 +1,50 @@
|
|||
FROM php:7.2-apache
|
||||
LABEL maintainer="Andy Miller <rhuk@getgrav.org> (@rhukster)"
|
||||
ARG PHP_VERSION=7.2
|
||||
|
||||
# Enable Apache Rewrite + Expires Module
|
||||
RUN a2enmod rewrite expires
|
||||
FROM php:${PHP_VERSION}-apache
|
||||
LABEL maintainer="Andy Miller <rhuk@getgrav.org> (@rhukster)" \
|
||||
maintainer="Romain Fluttaz <romain@fluttaz.fr>"
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
unzip \
|
||||
# install dependencies we need
|
||||
RUN set -ex; \
|
||||
\
|
||||
apt-get update; \
|
||||
apt-get install -y \
|
||||
unzip
|
||||
|
||||
# install the PHP extensions we need
|
||||
RUN set -ex; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
\
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
libyaml-dev \
|
||||
&& docker-php-ext-install opcache \
|
||||
&& 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
|
||||
libldap2-dev \
|
||||
; \
|
||||
\
|
||||
pecl install apcu; \
|
||||
pecl install yaml; \
|
||||
docker-php-ext-enable apcu yaml; \
|
||||
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
|
||||
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/; \
|
||||
docker-php-ext-install gd mysqli opcache zip ldap; \
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
|
||||
| awk '/=>/ { print $3 }' \
|
||||
| sort -u \
|
||||
| xargs -r dpkg-query -S \
|
||||
| cut -d: -f1 \
|
||||
| sort -u \
|
||||
| xargs -rt apt-mark manual; \
|
||||
\
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# set recommended PHP.ini settings
|
||||
# see https://secure.php.net/manual/en/opcache.installation.php
|
||||
|
|
@ -25,38 +55,40 @@ RUN { \
|
|||
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
|
||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
|
||||
|
||||
# provide container inside image for data persistance
|
||||
# VOLUME /var/www/html
|
||||
RUN { \
|
||||
echo 'upload_max_filesize = 128M'; \
|
||||
echo 'post_max_size = 128M'; \
|
||||
echo 'max_execution_time = 600'; \
|
||||
echo 'max_input_vars = 5000'; \
|
||||
} > /usr/local/etc/php/conf.d/php-optimisations.ini
|
||||
|
||||
RUN pecl install apcu \
|
||||
&& pecl install yaml \
|
||||
&& docker-php-ext-enable apcu yaml
|
||||
|
||||
# Set user to www-data
|
||||
RUN chown www-data:www-data /var/www
|
||||
USER www-data
|
||||
# Enable Apache Rewrite + Expires Module
|
||||
RUN a2enmod rewrite expires
|
||||
|
||||
VOLUME /var/www/html
|
||||
|
||||
RUN chown -R www-data:www-data /var/www
|
||||
|
||||
# Define Grav version and expected SHA1 signature
|
||||
ENV GRAV_VERSION 1.5.5
|
||||
ENV GRAV_SHA1 af0433facdae1afeb1d973a66db2315c5022b10d
|
||||
|
||||
# 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"]"]
|
||||
|
|
|
|||
85
README.md
85
README.md
|
|
@ -1,14 +1,19 @@
|
|||
# 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)_
|
||||
|
||||
* apache-2.4.8
|
||||
* GD library
|
||||
* Unzip library
|
||||
* php7.2
|
||||
* php7.2-opcache
|
||||
* php7.2-acpu
|
||||
* php7.2-yaml
|
||||
**Grav version : 1.5.3**
|
||||
|
||||
Fonctionnalities :
|
||||
|
||||
* apache-2.4.8
|
||||
* GD library
|
||||
* Unzip library
|
||||
* php7.2
|
||||
* php7.2-opcache
|
||||
* php7.2-acpu
|
||||
* php7.2-yaml
|
||||
* php7.2-ldap
|
||||
|
||||
## Building the image from Dockerfile
|
||||
|
||||
|
|
@ -16,26 +21,62 @@ This currently is pretty minimal and uses:
|
|||
docker build -t grav:latest .
|
||||
```
|
||||
|
||||
## Running Grav Image with Latest Grav + Admin (not persistent):
|
||||
## Running
|
||||
|
||||
```
|
||||
docker run -p 8000:80 grav:latest
|
||||
```
|
||||
You can find 2 version of this image, one on [gitlab botux-fr/docker/grav](https://gitlab.com/botux-fr/docker/grav) _with the CI tools_, the other on docker-hub, link to the [github repository boTux-fr/docker-grav](https://github.com/boTux-fr/docker-grav).
|
||||
|
||||
* Latest botux-grav image on gitlab : [Grav images @ gitlab](https://gitlab.com/botux-fr/docker/grav/container_registry).
|
||||
* Other version on hub.docker : [Grav images @ docker hub](https://hub.docker.com/r/botux/grav/)
|
||||
|
||||
### Running Grav Image with Latest Grav + Admin (not persistent):
|
||||
|
||||
docker run -p 8000:80 registry.gitlab.com/botux-fr/docker/grav:latest
|
||||
|
||||
Point browser to `http://localhost/8000` and create user account...
|
||||
|
||||
## Running local Grav installation
|
||||
### With docker-compose :
|
||||
|
||||
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.
|
||||
```yaml
|
||||
version: "3.6"
|
||||
|
||||
services:
|
||||
grav:
|
||||
image: registry.gitlab.com/botux-fr/docker/grav:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 8080:80
|
||||
volumes:
|
||||
- ./data/:/var/www/html/
|
||||
```
|
||||
docker run -v /local/grav/install:/var/www/html:cached -p 8000:80/tcp grav:latest
|
||||
```
|
||||
_And go on http://localhost:8080/_
|
||||
|
||||
To run in the current directory you can use:
|
||||
--------------------
|
||||
#### docker-compose and a reverse proxy like traefik
|
||||
|
||||
```
|
||||
docker run -v `pwd`:/var/www/html:cached -p 8000:80/tcp grav:latest
|
||||
```
|
||||
If you're using traefik as reverse proxy, you can use :
|
||||
|
||||
Point browser to `http://localhost/8000` to access your Grav site
|
||||
```yaml
|
||||
version: "3.6"
|
||||
|
||||
networks:
|
||||
reverse-proxy:
|
||||
name: reverse-proxy
|
||||
external: true
|
||||
|
||||
services:
|
||||
grav:
|
||||
image: registry.gitlab.com/botux-fr/docker/grav:latest
|
||||
restart: always
|
||||
networks:
|
||||
- reverse-proxy
|
||||
labels:
|
||||
- "traefik.docker.network=reverse-proxy"
|
||||
- "traefik.enable=true"
|
||||
- "traefik.port=80"
|
||||
- "traefik.backend=grav"
|
||||
- "traefik.frontend.passHostHeader=true"
|
||||
- "traefik.frontend.rule=Host:${DOMAIN:-my.domain.tld}"
|
||||
- "traefik.frontend.whiteList.sourceRange=${WHITELIST:-}"
|
||||
volumes:
|
||||
- ./data/:/var/www/html/
|
||||
```
|
||||
|
|
@ -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 "$@"
|
||||
|
||||
Loading…
Reference in New Issue