Skip to content

Commit

Permalink
Merge pull request #98 from hakkens/docker
Browse files Browse the repository at this point in the history
Docker all the things!
  • Loading branch information
davehakkens committed Jul 5, 2018
2 parents 3d159f0 + ec719bc commit 69c698c
Show file tree
Hide file tree
Showing 610 changed files with 343 additions and 134 deletions.
72 changes: 53 additions & 19 deletions Dockerfile
@@ -1,31 +1,65 @@
FROM php:5.6-apache

RUN a2enmod rewrite
FROM php:7.2-apache

# install the PHP extensions we need
RUN apt-get update && apt-get install -y libmcrypt-dev libpng12-dev libjpeg-dev && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install -j$(nproc) mcrypt \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd
RUN docker-php-ext-install mysqli
RUN set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libjpeg-dev \
libpng-dev \
libmcrypt-dev \
; \
\
pecl install mcrypt-1.0.1; \
docker-php-ext-enable mcrypt; \
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
docker-php-ext-install gd mysqli opcache zip; \
\
# 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
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
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 a2enmod rewrite expires

VOLUME /var/www/html

ENV WORDPRESS_VERSION 4.8
ENV WORDPRESS_UPSTREAM_VERSION 4.8
ENV WORDPRESS_SHA1 3738189a1f37a03fb9cb087160b457d7a641ccb4
ENV WORDPRESS_VERSION 4.9.6
ENV WORDPRESS_SHA1 40616b40d120c97205e5852c03096115c2fca537

RUN set -ex; \
curl -o wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"; \
echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c -; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
RUN curl -o wordpress.tar.gz -SL https://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz \
&& echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c - \
&& tar -xzf wordpress.tar.gz -C /usr/src/ \
&& rm wordpress.tar.gz \
&& chown -R www-data:www-data /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress

COPY docker-entrypoint.sh /entrypoint.sh
COPY docker-entrypoint.sh /usr/local/bin/

# grr, ENTRYPOINT resets CMD now
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["chown www-data:www-data -R /var/www/html/wp-content/themes"]
CMD ["a2enmod rewrite"]
CMD ["apache2-foreground"]
68 changes: 55 additions & 13 deletions README.md
@@ -1,8 +1,14 @@
# davehakkens
WordPress theme for the Dave Hakkens Community website

We wanted to have a place online which is truly ours, we are in control. No adds, open-source, build together in the way we want it to be. We started of building this thing, but invite you to help out and share feedback. It's build on Wordpress, we know. Not the best software to build a community on. But we like that it is a language many developers from all over the world speak. Which makes it easy to work on together. And we are always looking for passionate developers that want to help out improving this place. If you are one of those, reach out to us in the forums at http://davehakkens.nl/community

We wanted to have a place online which is truly ours, we are in control. No
ads, open-source, build together in the way we want it to be. We started of
building this thing, but invite you to help out and share feedback. It's build
on Wordpress, we know. Not the best software to build a community on. But we
like that it is a language many developers from all over the world speak. Which
makes it easy to work on together. And we are always looking for passionate
developers that want to help out improving this place. If you are one of those,
reach out to us in the forums at http://davehakkens.nl/community

It's running on Wordpress.
Couple of key plugins we use to make this community happen
Expand All @@ -13,26 +19,62 @@ Couple of key plugins we use to make this community happen

## Getting started using Docker

Make sure you have docker installed with docker compose
The theme has some dependencies that need to be installed before you will be
able to test anything. A script has been created which automates some of this
setup for you.

To Run:
*NOTE*: The setup script does a destructive change to the current docker
containers that you have already built. This means you lose all the data and
start from scratch again.

docker-compose up -d
To run the setup script, should just need to run

./setup.sh

Then browse to http://localhost:8000/
Currently only works on Mac/Linux (sorry windows users)

To bring offline
Once everything has completed (might take a minute or so), then you should be
safe to browse to http://localhost:8001/

If you change something in the congif of the docker image, you might need to
restart all the containers. You can do this by running:

docker-compose down
docker-compose up -d

After install, you will probably need to do the following:

- WP admin -> Plugins -> Buddypress -> Settings -> Enable Private Messaging
- Enable the dave hakkens theme

### Things to help you debug

#### Pulling up a bash prompt

Sometimes being able to get root access to a machine is nice. You can do this
on the wordpress image by running:

docker exec -it davehakkens_wordpress /bin/bash

When you first install, you will need to install plugins and select the Dave Hakkens theme. Plugins and theme selection should persist
#### Accessing the database

Since the pages are part of the database, you will need to create the community page, and a login page (parented to the community page to not break links). This will enable you to get back in once you restart the container
You can do this a couple of ways. If you're happy to run commands directly on
mysql server, you will need to log into the container and run mysql. This can
be done by:

## Creating custom pins tables
docker exec -it davehakkens_database /bin/bash
mysql -p wordpress
# this prompts for a password. Default is "somewordpress"

After first boot of the containers, you will need to create the map table (used for pin queries). You can use the following command to create the table:
This image also includes a php myadmin install. To get to the phpmyadmin page,
make sure the image(s) are running and goto http://localhost:8002/. Put `db` in
the Database field, `root` as user, and the default database password in the
password (currently `somewordpress`)

cat pp_pins_create.sql | docker exec -i 3c205c210033 mysql --user=<username> --password=<password> -D <database>
### TODO

By default, username, password, and database are all `wordpress` according to the docker file
- Automate enable private messaging. Can't find a bp function, so might need
to edit the option\_value under wp\_options table
- Automate the activation of the theme (setup.sh)
- Automate creation of pages and buddypress mapping (login + community,
parented to community so static links don't break)
19 changes: 17 additions & 2 deletions docker-compose.yml
Expand Up @@ -2,9 +2,12 @@ version: '3.0'

services:
db:
container_name: davehakkens_database
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
Expand All @@ -13,20 +16,32 @@ services:
MYSQL_PASSWORD: wordpress

wordpress:
container_name: davehakkens_wordpress
depends_on:
- db
build: .
volumes:
- wp_data:/var/www/html
- ./:/var/www/html/wp-content/themes/davehakkens
- ./theme/:/var/www/html/wp-content/themes/davehakkens
ports:
- "8000:80"
- "8001:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress

phpmyadmin:
container_name: davehakkens_phpmyadmin
image: phpmyadmin/phpmyadmin
depends_on:
- db
restart: always
ports:
- "8002:80"
environment:
- PMA_ARBITRARY=1

volumes:
db_data:
wp_data:

0 comments on commit 69c698c

Please sign in to comment.