I am trying to create a simple local docker setup with Grav CMS (getgrav.org).
I have successfully gotten the docker container to spin up and server me the proper files, however when I try to create a mounted volume for the "user" directory of the CMS things seem to break.
Here is my Dockerfile:
FROM php:7-apache
RUN set -xe \
&& mkdir -p /usr/src/grav/.unpacked \
&& apt-get update && apt-get install -y libpng12-0 git unzip libpng12-dev --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install gd zip \
&& a2enmod rewrite
ENV GRAV_URL "https://getgrav.org/download/core/grav/1.3.3"
RUN set -xe \
&& curl -fSL -o /usr/src/grav/grav.zip "$GRAV_URL" \
&& unzip /usr/src/grav/grav.zip -d /usr/src/grav/.unpacked \
&& rm /usr/src/grav/grav.zip \
&& mv /usr/src/grav/.unpacked/*/* /usr/src/grav \
&& mv /usr/src/grav/.unpacked/*/.[!.]* /usr/src/grav \
&& rm -rf /usr/src/grav/.unpacked \
&& chown -R www-data:www-data /usr/src/grav \
&& cd /usr/src/grav \
&& bin/gpm selfupgrade -y \
&& bin/gpm install -y admin git-sync
VOLUME /var/www/html
COPY ./docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/bin/sh", "/entrypoint.sh" ]
CMD [ "apache2-foreground" ]
My docker-compose.yml file:
version: '2'
services:
grav:
image: grav
container_name: gravdocker
ports:
- "8080:80"
environment:
VIRTUAL_HOST: gravlocal.docker
and my docker-entrypoint.sh:
#!/bin/sh
set -e
if [ -z "$(ls -A /var/www/html)"]; then
cp -a /usr/src/grav/. /var/www/html/
chown -R www-data:www-data /var/www/html
if [ "$GRAV_REVERSE_PROXY" = "true" ]; then
sed -i "s/reverse_proxy_setup:\sfalse/reverse_proxy_setup: true/g" \
system/config/system.yaml
fi
fi
exec "$@"
With this setup everything is okay. When I add
volumes:
- ./user:/var/www/html/user
to the docker-compose file, I get a forbidden error in the browser. When I try to specify another volume in the dockerfile for the user directory it also gives me a forbidden warning in the browser.
My goal is to have the CMS running in docker and listening for a user directory locally so I can do theme development and have a local version of the files.