Dockerfile 1.71 KB
Newer Older
1 2 3 4 5
# docker Drupal
# VERSION       0.3
FROM    savoirfairelinux/lampd
MAINTAINER Ernesto Rodriguez Ortiz <ernesto.rodriguezortiz@savoirfairelinuc.com>

6 7 8 9
# Create project root directory and copy the structure
RUN mkdir -p /opt/sfl/src/drupal
COPY . /opt/sfl

10 11
# Create user used by Drupalizer tasks
RUN useradd --home-dir /opt/init --create-home drupalizer --shell /bin/bash && passwd -d drupalizer
12
RUN echo 'cd /opt/sfl/src/drupal' > /opt/init/.profile
13

14 15 16 17
# Setup SSH access
RUN mkdir -p /opt/init/.ssh && echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDcJHyU5S4xRP4QyJuBOiS38mrEuwfgOoWoNFQM0gWhJCb2phByO4Xg68f4v0w3FWm2SQQKv3bG5aevTI2ST5n0o/GbcCpdT1udV9uQIxr1+cbXUrecaNPD3WyIxt1Rldtwm7+s0AlwHHk0zKvulyupzPfQGB4Ix0zUfIzt+U45ww==' \
> /opt/init/.ssh/authorized_keys

18 19 20
# Create entrypoint script
RUN echo '#!/bin/bash\n\
\n\
21 22 23 24 25 26 27 28 29 30 31 32
if [[ ! -z "$USER_ID" ]]\n\
then\n\
    which usermod 2>&1 >/dev/null && usermod -u $USER_ID drupalizer\n\
    service apache2 reload\n\
fi\n\
\n\
if [[ ! -z "$GROUP_ID" ]]\n\
then\n\
    which groupmod 2>&1 >/dev/null && groupmod -g $GROUP_ID drupalizer\n\
    service apache2 reload\n\
fi\n\
\n\
33 34 35
exec /bin/sh -c "$*"'\
> /opt/init/init.sh && chmod a+x /opt/init/init.sh

36 37 38 39 40 41 42 43 44 45 46 47
# Create Apache configuration
RUN echo 'ServerName localhost\n\
<VirtualHost *:80>\n\
    DocumentRoot /opt/sfl/src/drupal\n\
\n\
    <Directory /opt/sfl/src/drupal/>\n\
        AllowOverride All\n\
        Options FollowSymLinks\n\
        Require all granted\n\
    </Directory>\n\
</VirtualHost>'\
> /etc/apache2/sites-available/000-default.conf
48
RUN echo 'export APACHE_RUN_USER=drupalizer\nexport APACHE_RUN_GROUP=drupalizer' >> /etc/apache2/envvars
49
RUN a2enmod rewrite vhost_alias && service apache2 restart
50 51 52

ENTRYPOINT ["/opt/init/init.sh"]
CMD ["/sbin/my_init"]