├── .env ├── .environment ├── .docker-wp │ ├── Dockerfile │ └── setup.sh ├── .gitignore └── docker-compose.yml ├── .github ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── ADVANCED.md └── README.md /.env: -------------------------------------------------------------------------------- 1 | # Basic Compoe Settings 2 | # --------------------- 3 | # notes: 4 | # - COMPOSE_PROJECT_NAME : set this to a unique project name 5 | # --------------------- 6 | COMPOSE_PROJECT_NAME=wp_local_docker 7 | 8 | # General & Shared 9 | # --------------------- 10 | DB_NAME=wp_local_docker 11 | DB_USER=wordpress 12 | DB_PASS=wordpress 13 | 14 | # WordPress Settings 15 | # --------------------- 16 | VERSION='latest' 17 | MULTISITE='false' 18 | SITE_TITLE='WordPress on Docker' 19 | DB_HOST=db 20 | DB_PREFIX=_wp 21 | ADMIN_EMAIL=wp@dev.com 22 | WP_DEBUG='true' 23 | WP_DEBUG_DISPLAY='true' 24 | WP_DEBUG_LOG='true' 25 | 26 | # Advanced 27 | # --------------------- 28 | WEB_PORT=8000 29 | MAILHOG_PORT=8001 30 | MYSQL_PORT=3306 31 | PHP_DOCROOT=./ 32 | PHP_SITE_NAME=dev 33 | PHP_HOST_NAME=localhost:8000 34 | PHP_SENDMAIL_PATH=/usr/sbin/sendmail -t -i -S mailhog:1025 35 | PHP_XDEBUG_ENABLED=0 36 | NGINX_SERVER_NAME=localhost 37 | NGINX_UPSTREAM_NAME=wp 38 | NGINX_DOCROOT=./ 39 | COMPOSE_FILE=./.environment/docker-compose.yml 40 | -------------------------------------------------------------------------------- /.environment/.docker-wp/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM wodby/wordpress-php 2 | MAINTAINER Paul van Zyl 3 | 4 | # set the working directory 5 | WORKDIR "/var/www/html" 6 | 7 | # expose the port for nginx container 8 | EXPOSE 9000 9 | 10 | # Install dependencies 11 | RUN \ 12 | echo "fetching and installing dependancies..." \ 13 | && apk add --update --no-cache bash sudo gawk sed grep bc coreutils 14 | 15 | # Copy in start script 16 | COPY setup.sh /usr/local/bin/ 17 | 18 | # Run start script 19 | CMD ["bash", "/usr/local/bin/setup.sh"] 20 | -------------------------------------------------------------------------------- /.environment/.docker-wp/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set Environmental Variables 4 | # - - - - - - - - - 5 | set_envs() { 6 | SITE_TITLE=${SITE_TITLE:-'freshpress'} 7 | DB_HOST=${DB_HOST:-'db'} 8 | DB_NAME=${DB_NAME:-'wordpress-default'} 9 | DB_PASS=${DB_PASS:-'wordpress-default'} 10 | DB_USER=${DB_USER:-'root'} 11 | DB_PREFIX=${DB_PREFIX:-'wp_'} 12 | WP_VERSION=${WP_VERSION:-'latest'} 13 | ADMIN_EMAIL=${ADMIN_EMAIL:-"admin@freshpress.com"} 14 | WP_DEBUG_DISPLAY=${WP_DEBUG_DISPLAY:-'true'} 15 | WP_DEBUG_LOG=${WB_DEBUG_LOG:-'false'} 16 | WP_DEBUG=${WP_DEBUG:-'false'} 17 | MULTISITE=${MULTISITE:-'false'} 18 | [ "$SEARCH_REPLACE" ] && \ 19 | BEFORE_URL=$(echo "$SEARCH_REPLACE" | cut -d ',' -f 1) && \ 20 | AFTER_URL=$(echo "$SEARCH_REPLACE" | cut -d ',' -f 2) || \ 21 | SEARCH_REPLACE=false 22 | } 23 | 24 | # General Purpose Error Function 25 | # - - - - - - - - - - - - - - - - 26 | ERROR() { 27 | echo -e "\n=> (Line $1): $2."; 28 | exit 1; 29 | } 30 | 31 | # Configure wp-cli 32 | # ---------------- 33 | wpcli_config() { 34 | cat > /wp-cli.yml < Downloading wordpress... " 64 | chown -R www-data:www-data /var/www/html 65 | sudo -u www-data wp core download --version=$WP_VERSION >/dev/null 2>&1 || \ 66 | ERROR $LINENO "Failed to download wordpress" 67 | printf "Done!\n" 68 | else 69 | printf "WordPress is installed \n" 70 | fi 71 | } 72 | 73 | 74 | # Wait for MySQL 75 | # -------------- 76 | wait_for_mysql() { 77 | printf "=> Waiting for MySQL to initialize... \n" 78 | while ! mysqladmin ping --host=$DB_HOST --password=$DB_PASS --silent; do 79 | printf "...ping" 80 | sleep 1 81 | done 82 | } 83 | 84 | 85 | 86 | # wp-config.php 87 | # ------------- 88 | setup_wp_config() { 89 | printf "=> Generating wp.config.php file... " 90 | rm -f /var/www/html/wp-config.php 91 | sudo -u www-data wp core config --allow-root >/dev/null 2>&1 || \ 92 | ERROR $LINENO "Could not generate wp-config.php file" 93 | printf "Done!\n" 94 | } 95 | 96 | 97 | 98 | # Setup database 99 | # -------------- 100 | setup_db() { 101 | printf "=> Create database '%s'... " "$DB_NAME" 102 | if [ ! "$(wp core is-installed --allow-root >/dev/null 2>&1 && echo $?)" ]; then 103 | 104 | sudo -u www-data wp db create >/dev/null 2>&1 || true 105 | printf "Done!\n" 106 | 107 | # If an SQL file exists in /data => load it 108 | if [ "$(stat -t /data/*.sql >/dev/null 2>&1 && echo $?)" ]; then 109 | DATA_PATH=$(find /data/*.sql | head -n 1) 110 | printf "=> Loading data backup from %s... " "$DATA_PATH" 111 | sudo -u www-data wp db import "$DATA_PATH" >/dev/null 2>&1 || \ 112 | ERROR $LINENO "Could not import database" 113 | printf "Done!\n" 114 | 115 | # If SEARCH_REPLACE is set => Replace URLs 116 | if [ "$SEARCH_REPLACE" != false ]; then 117 | printf "=> Replacing URLs... " 118 | REPLACEMENTS=$(sudo -u www-data wp search-replace "$BEFORE_URL" "$AFTER_URL" \ 119 | --no-quiet --skip-columns=guid | grep replacement) || \ 120 | ERROR $((LINENO-2)) "Could not execute SEARCH_REPLACE on database" 121 | echo -ne "$REPLACEMENTS\n" 122 | fi 123 | else 124 | printf "=> No database backup found. Initializing new database... " 125 | sudo -u www-data wp core install >/dev/null 2>&1 || \ 126 | ERROR $LINENO "WordPress Install Failed" 127 | printf "Done!\n" 128 | fi 129 | else 130 | printf "Already exists!\n" 131 | fi 132 | } 133 | 134 | 135 | 136 | # Make multisite 137 | # --------------- 138 | do_multisite() { 139 | printf "=> Turn wordpress multisite on... " 140 | if [ "$MULTISITE" == "true" ]; then 141 | sudo -u www-data wp core multisite-convert >/dev/null 2>&1 || \ 142 | ERROR $LINENO "Failed to turn on wordpress multisite" 143 | printf "Done!\n" 144 | else 145 | printf "Skip!\n" 146 | fi 147 | } 148 | 149 | run() { 150 | 151 | printf "starting run script......" 152 | cd /var/www/html/ 153 | 154 | # init functions 155 | set_envs 156 | wpcli_config 157 | download_wp 158 | 159 | printf "\t%s\n" \ 160 | "=======================================" \ 161 | " Begin WordPress Configuration" \ 162 | "=======================================" 163 | 164 | # wp functions 165 | wait_for_mysql 166 | setup_wp_config 167 | setup_db 168 | do_multisite 169 | 170 | printf "\t%s\n" \ 171 | "=======================================" \ 172 | " WordPress Configuration Complete!" \ 173 | "=======================================" 174 | } 175 | 176 | # setup and prepare 177 | run 178 | 179 | # Start PHP processing 180 | exec /usr/local/bin/docker-entrypoint.sh 181 | -------------------------------------------------------------------------------- /.environment/.gitignore: -------------------------------------------------------------------------------- 1 | data/ 2 | temp/ 3 | -------------------------------------------------------------------------------- /.environment/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | services: 4 | # a lighter drop in replacement for MySQL 5 | db: 6 | image: wodby/wordpress-mariadb 7 | environment: 8 | MYSQL_ROOT_PASSWORD: ${DB_PASS} 9 | MYSQL_DATABASE: ${DB_NAME} 10 | MYSQL_USER: ${DB_USER} 11 | MYSQL_PASSWORD: ${DB_PASS} 12 | ports: 13 | - 3306:3306 14 | 15 | # WordPress running on PHP-FPM 16 | wp: 17 | build: 18 | context: ./.docker-wp 19 | links: 20 | - db 21 | environment: 22 | - PHP_DOCROOT 23 | - PHP_SITE_NAME 24 | - PHP_HOST_NAME 25 | - PHP_SENDMAIL_PATH 26 | - PHP_XDEBUG_ENABLED 27 | - SITE_TITLE 28 | - DB_HOST 29 | - DB_NAME 30 | - DB_USER 31 | - DB_PASS 32 | - DB_PREFIX 33 | - ADMIN_EMAIL 34 | - WP_DEBUG 35 | - WP_DEBUG_DISPLAY 36 | - WP_DEBUG_LOG 37 | - MULTISITE 38 | - VERSION 39 | volumes: 40 | # mounted in for normal wp operation, into hidden folder(s) 41 | - ./.wp:/var/www/html/ 42 | - ./.plugins:/var/www/html/wp-content/plugins 43 | - ./.uploads:/var/www/html/wp-content/uploads 44 | - ./.themes:/var/www/html/wp-content/themes 45 | # custom theme or plugin folder, add all project specific folders here 46 | - ./../theme:/var/www/html/wp-content/themes/tortoisehare 47 | 48 | # Our Web Server serving files from the php-fpm container 49 | nginx: 50 | image: wodby/wordpress-nginx 51 | environment: 52 | - NGINX_SERVER_NAME 53 | - NGINX_UPSTREAM_NAME 54 | - NGINX_DOCROOT 55 | volumes_from: 56 | - wp 57 | ports: 58 | - "${WEB_PORT}:80" 59 | 60 | # Catch Mail for local development 61 | mailhog: 62 | image: mailhog/mailhog 63 | ports: 64 | - "${MAILHOG_PORT}:8025" 65 | -------------------------------------------------------------------------------- /.github/CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | This code of conduct outlines our expectations for participants within the 2 | **Nona Creative** orgnaisation and community. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. 3 | 4 | We strives to: 5 | 6 | - **Be friendly and patient.** 7 | - **Be welcoming**: We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability. 8 | - **Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we’re a world-wide community, so you might not be communicating in someone else’s primary language. 9 | - **Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a company or community where people feel uncomfortable or threatened is not a productive one. 10 | - **Be careful in the words that we choose**: we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren’t acceptable. 11 | - **Try to understand why we disagree**: Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of our company, and community, comes from its diversity. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues, learning from mistakes, and moving forward. 12 | 13 | 14 | 15 | ## Definitions 16 | 17 | Harassment includes, but is not limited to: 18 | 19 | - Offensive comments related to gender, gender identity and expression, sexual 20 | orientation, disability, mental illness, neuro(a)typicality, physical 21 | appearance, body size, race, age, regional discrimination, political or 22 | religious affiliation 23 | - Unwelcome comments regarding a person’s lifestyle choices and practices, 24 | including those related to food, health, parenting, drugs, and employment 25 | - Deliberate misgendering. This includes deadnaming or persistently using a 26 | pronoun that does not correctly reflect a person’s gender identity. You must 27 | address people by the name they give you when not addressing them by their 28 | username or handle 29 | - Physical contact and simulated physical contact (eg, textual descriptions like “*hug*” or “*backrub*”) without consent or after a request to stop 30 | - Threats of violence, both physical and psychological 31 | - Incitement of violence towards any individual, including encouraging a person 32 | to commit suicide or to engage in self-harm 33 | - Deliberate intimidation 34 | - Stalking or following 35 | - Harassing photography or recording, including logging online activity for 36 | harassment purposes 37 | - Sustained disruption of discussion 38 | - Unwelcome sexual attention, including gratuitous or off-topic sexual images or behaviour 39 | - Pattern of inappropriate social contact, such as requesting/assuming inappropriate levels of intimacy with others 40 | - Continued one-on-one communication after requests to cease 41 | - Deliberate “outing” of any aspect of a person’s identity without their consent except as necessary to protect others from intentional abuse 42 | - Publication of non-harassing private communication 43 | 44 | Our company prioritizes marginalized people’s safety over 45 | privileged people’s comfort. We will not act on complaints regarding: 46 | 47 | - ‘Reverse’ -isms, including ‘reverse racism,’ ‘reverse sexism,’ and ‘cisphobia’ 48 | - Reasonable communication of boundaries, such as “leave me alone,” “go away,” 49 | or “I’m not discussing this with you” 50 | - Refusal to explain or debate social justice concepts 51 | - Communicating in a ‘tone’ you don’t find congenial 52 | - Criticizing racist, sexist, cissexist, or otherwise oppressive behavior or 53 | assumptions 54 | 55 | 56 | 57 | ### Diversity Statement 58 | 59 | We encourage everyone to participate and are committed to building an organisation and community for all. Although we will fail at times, we seek to treat everyone both as fairly and equally as possible. Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do our best to right the wrong. 60 | 61 | Although this list cannot be exhaustive, we explicitly honor diversity in age, gender, gender identity or expression, culture, ethnicity, language, national origin, political beliefs, profession, race, religion, sexual orientation, socioeconomic status, and technical ability. We will not tolerate discrimination based on any of the protected characteristics above, including participants with disabilities. 62 | 63 | 64 | ___ 65 | 66 | 67 | 68 | ### Attribution & Acknowledgements 69 | 70 | - [Brigade Media](https://github.com/brigade/code-of-conduct/blob/master/README.md) 71 | - [Django](https://www.djangoproject.com/conduct/reporting/) 72 | - [Python](https://www.python.org/community/diversity/) 73 | - [Ubuntu](http://www.ubuntu.com/about/about-ubuntu/conduct) 74 | - [Contributor Covenant](http://contributor-covenant.org/) 75 | - [Geek Feminism](http://geekfeminism.org/about/code-of-conduct/) 76 | - [Citizen Code of Conduct](http://citizencodeofconduct.org/) 77 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | To keep our repositories as uniform as possible, and work together effectively please consider the following. 3 | 4 | ## Our Git workflow 5 | 6 | Clearly, as we're on Github, we're using Git to manage our codebases, code review and versioning. If you're new to Git, or Gitflow please see the following links: 7 | 8 | * [Get Git Quickly](https://learnxinyminutes.com/docs/git/) 9 | * [Git cheat sheet](https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf) 10 | * [Github Flow - basic concept](https://guides.github.com/introduction/flow/) 11 | * [Atlassian Comparing Git Workflows](https://www.atlassian.com/git/tutorials/comparing-workflows/) 12 | * [Atlassian Advanced Git Tutorials](https://www.atlassian.com/git/tutorials/advanced-overview/) 13 | 14 | ### Feature branch workflow - small projects 15 | 16 | For smaller projects we're following this feature branch workflow that can be found [here](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) 17 | 18 | ### Gitflow workflow - larger projects 19 | 20 | This [workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) is better suited to larger, ongoing projects with multiple releases and CI. 21 | 22 | We use two primary branches. `master` and `development`. `development` is what you'll create pull requests against, and should be deployed to staging environments for testing. 23 | 24 | Once enough work has gone in to create a deliverable and deployable piece of value, and all testing is complete we create a release branch (this is where we start adding version numbers, add documentation and do any prep related to the release). 25 | 26 | This then gets merged into `master`, which will then be deployed to a production environment. 27 | 28 | We should merge `master` back into `development` only if hotfix issues have been merged and deployed. Ideally `master` should always represent what is in production. 29 | 30 | ### Contributing to the project 31 | Always branch, and use the below naming schema for branches. Once you've completed the work for that branch, push it up to Github and open a pull request against `development`. 32 | 33 | As with issues, and pull requests we're aiming to keep branches as short lived as possible, this reduces transaction costs, review time, merge conflicts and helps build momentum in the team. 34 | 35 | #### Naming branches 36 | We prefix our branch names to make it easier to see what branches relate to. 37 | 38 | * `feature/` - a new feature 39 | * `fix/` - fixes an issue 40 | * `style/` - small front end updates 41 | * `hotfix/` - fixes against a release 42 | * `release/` - preparing for a release 43 | 44 | ### Pull requests 45 | Pull requests should be kept as small as possible and solve a single problem. This eases review and avoids unnecessary merge conflicts. Pull requests should be reviewed by two team members. 46 | 47 | **NB :** For front-end changes and style fixes, adding screenshots to the pull request is tremendously helpful in explaining what was done and why. 48 | 49 | ### Merging and deleting 50 | Once two thumbs up :+1 have been received on a pull request, and all issues resolved, it should be merged quickly to avoid becoming "stale". Once merged, the branch should be deleted on Github. 51 | 52 | ### Commits and commit messages 53 | Commits should also be kept as small as possible. 54 | 55 | Commit titles should be 80 characters or shorter and additional descriptions should be used when necessary. 56 | 57 | ### Issues 58 | If you think you've found a bug, or have a concern, check that its not already in the current issues, and then use the issue template if appropriate, if design/style related screenshots are helpful, and if it's a feature please describe it fully. If you're aware of who worked on the related functionality, mention them in the comments rather than assigning them. 59 | 60 | ### Versioning things 61 | When it's neccessary to use versioning we should follow the Semver pattern as discussed [here](http://semver.org/). 62 | 63 | We using a three number system, e.g.: `1.2.3`: 64 | 65 | 1. MAJOR version when you make incompatible API changes `1` 66 | 2. MINOR version when you add functionality in a backwards-compatible manner `2` 67 | 3. PATCH version when you make backwards-compatible bug fixes `3` 68 | 69 | ### Maintaining the ReadMe 70 | This should be regularly updated with project details and developer instructions, particularly for setup, and any specific release instructions and notes. 71 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Scope 2 | 3 | 4 | ## To reproduce 5 | To reproduce this issue : 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Scope 2 | 3 | 4 | ### Work done 5 | 6 | 7 | ## Steps to test 8 | 9 | 10 | ## Screenshots 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### OSX ### 2 | .DS_Store 3 | */.DS_Store 4 | .DS_Store? 5 | .AppleDouble 6 | .LSOverride 7 | 8 | # Thumbnails 9 | ._* 10 | 11 | # Files that might appear on external disk 12 | .Spotlight-V100 13 | .Trashes 14 | 15 | # Directories potentially created on remote AFP share 16 | .AppleDB 17 | .AppleDesktop 18 | Network Trash Folder 19 | Temporary Items 20 | .apdisk 21 | 22 | ### Windows ### 23 | # Windows image file caches 24 | Thumbs.db 25 | ehthumbs.db 26 | 27 | # Folder config file 28 | Desktop.ini 29 | 30 | # Recycle Bin used on file shares 31 | $RECYCLE.BIN/ 32 | 33 | # Windows Installer files 34 | *.cab 35 | *.msi 36 | *.msm 37 | *.msp 38 | 39 | # Dependency directories 40 | node_modules 41 | .sass-cache 42 | .npm 43 | npm-debug.log 44 | bower_components 45 | *.orig 46 | .build 47 | .idea/ 48 | docker-runtime/ 49 | assets/sass/lib/ 50 | 51 | # Project Specific 52 | .phpintel/ 53 | .plugins/ 54 | .uploads/ 55 | .wp/ 56 | .themes/ 57 | data/ 58 | theme/public 59 | -------------------------------------------------------------------------------- /ADVANCED.md: -------------------------------------------------------------------------------- 1 | # Advanced Setup 2 | The environment is setup for theme development by default. To create a new theme simply begin creating it in the theme folder, or follow the instructions below in the "advanced setup" section. 3 | 4 | ## Developing a Theme or Plugin 5 | If you'd like to be more selective about your project structure, or what you map into the container, you can do this by editing the `.environment/docker-compose.yml` file. scroll to the `volumes` section defined under the `php` container, and customise it for your project. If you'd prefer to mount in a single theme directory, or plugin directory remove the default volumes for plugins and themes listed and add the following: 6 | 7 | ```sh 8 | # for a custom theme 9 | - ./../:/var/www/html/wp-content/themes/ 10 | # for a custom plugin 11 | - ./../:/var/www/html/wp-content/plugins/ 12 | ``` 13 | 14 | if you add a custom volume after starting your project, you will have to restart your docker containers. 15 | 16 | 17 | ## Extending The Environment 18 | One of the major benefits of using docker is how easy it can be to extend your setup withadditional dependancies. Simply edit the `docker-compose.yml` file in the `.environment` directory. for example: 19 | 20 | ```yaml 21 | # redis 22 | redis: 23 | image: redis:3.2-alpine 24 | 25 | # memcached 26 | memcached: 27 | image: memcached:1.4-alpine 28 | 29 | # elasticsearch 30 | elasticsearch: 31 | image: elasticsearch:5.1.1-alpine 32 | ``` 33 | 34 | Look up these and more images on [docker hub](https://hub.docker.com/) where you'll find any available documentation. You'll notice that we're using the alpine versions for all images, which keeps the images and container sizes much slimmer. 35 | 36 | 37 | 38 | 39 | # Notes 40 | Its worth spending some time getting to grips with the fundementals of docker and docker compose if you haven't worked with it before. 41 | 42 | ## Why Docker for WordPress 43 | * Minimal system requirements and quick setup 44 | * Easy shareability between developers 45 | * Lightening fast project setup times as new containers are created from images stored on your system after the first setup 46 | * incredibly easy to learn, configure, change, extend and then share 47 | * paves the way for scalable docker deployments 48 | 49 | 50 | ## Basic Concepts 51 | By Comparison to Vagrant which creates Virtual Machines in minutes, Docker creates Virtual Containers in seconds. 52 | 53 | Instead of providing a full Virtual Machine, like you get with Vagrant, Docker provides you lightweight Virtual Containers, that share the same kernel and allow to safely execute independent processes. 54 | 55 | Fundementally, docker relies on "images", once an image is downloaded, you work with a single or set of "containers", which are instances of an image. This is why setting up a new environment for each project is so quick, as its creating your containers from locally stored images. Docker compose allows us to "compose" a set of images as an environment. 56 | 57 | You will be creating a set of isolated containers for each project, so if you require unique dependancies for that project, adjusting it without affecting your entire development machine becomes trivial. 58 | 59 | Learn more about docker by having a look at the documentation here: https://docs.docker.com/ 60 | 61 | 62 | ## Quick Docker Compose Commands Reference 63 | * up with logging : `docker-compose up` 64 | * up without logging : `docker-compose up -d` 65 | * rebuild : `docker-compose up build` 66 | * pass the container name after build to target a specific container 67 | * remove specific container : `docker-compose rm ` 68 | * list all docker images on your system: `docker images` 69 | * list all containers: `docker ps -a`. 70 | 71 | ## Rebuild the stack 72 | if you'd like to rebuild the stack run the following: 73 | 74 | ```sh 75 | # remove the containers for this project 76 | docker-compose rm php mariadb nginx mailhog 77 | 78 | # build the stack again 79 | docker-compose build 80 | ``` 81 | ## Common Issues 82 | 83 | 84 | - undoubtedly more coming soon. 85 | 86 | 87 | ___ 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wordpress-docker-local-environment 2 | Local WordPress Development Environment Using Docker, quickly configurable for theme and plugin development. 3 | 4 | 5 | ### This Environment Includes: 6 | 7 | * DB - MariaDB (MySQL drop-in replacement) 8 | * PHP7 - PHP is processed in its own container using PHP FPM 9 | * includes standard PHP & WP tooling such as sendmail, wp-cli, composer etc. 10 | * NginX - Web Server 11 | * MailHog - Mail Catcher for local dev 12 | 13 | ## requirements 14 | First install docker following the instructions below. 15 | 16 | * Git 17 | * Docker - https://www.docker.com/products/overview 18 | 19 | ## Table of Contents 20 | 21 | 22 | 23 | - [Quick Start](#quick-start) 24 | - [What you get](#what-you-get) 25 | - [Credits and Inspiration](#credits-and-inspiration) 26 | - [Contributions and Suggestions Welcome!](#contributions-and-suggestions-welcome) 27 | - [License MIT](#license-mit) 28 | 29 | 30 | 31 | 32 | # Quick Start 33 | This is simply using [docker-compose](https://docs.docker.com/compose/overview/), so starting and stopping the environment, or accessing specific containers is done by using standard docker-compose commands. 34 | 35 | 1. with docker installed, clone the repo into a new folder 36 | 37 | ```sh 38 | # get the git repo 39 | git clone git@github.com:Pushplaybang/wordpress-docker-local-environment.git . --depth=1 40 | # remove the git 41 | rm -Rf .git 42 | # initialize a new repository 43 | git init 44 | ``` 45 | 46 | 2. In the `.env` file set `COMPOSE_PROJECT_NAME` to a unique name for your project. This is the only environment variable in `.env` file that you **need** to set, change the others at your own risk, and at will. 47 | 48 | 3. In your terminal from the project root, run `docker-compose up` (show container logs) or `docker-compose up -d` (for no logs). To stop the environment, press `ctrl+C` or run `docker-compose stop` or `docker-compose kill`. 49 | 50 | **Adavnced config :** For additional documentation view the [advanced notes](https://github.com/Pushplaybang/wordpress-docker-local-environment/blob/master/ADVANCED.md) 51 | 52 | ## What you get 53 | Once your environment starts it will create a theme folder, this is mapped to the wp-content folder in the wordpress php container. should you wish to map other folders, such as for a custom plugin etc, have a look at the [Advanced Setup]((https://github.com/Pushplaybang/wordpress-docker-local-environment/blob/master/ADVANCED.md) readme. 54 | 55 | * access the wordpress site at `http://localhost:8000/` 56 | * access mailhog at `http://localhost:8001/` 57 | * connect to your DB via `http://localhost:3306` 58 | * the default username and password are both `wplocal`, (same for db) if you change these in the `.env` file, use your custom username and password, you may also want to update 59 | 60 | 61 | # Credits and Inspiration 62 | When looking for a docker setup for wordpress none of them satified all of me needs, from php7 and nginx to having working email, flexible project setup, splitting the services out, using alpine base images, or putting wordpress inside the container rather than bloating your project directory. This was inspired by the work done on the following projects: 63 | 64 | * https://github.com/Wodby/docker4wordpress 65 | * https://wckr.github.io/ 66 | * https://github.com/visiblevc/wordpress-starter 67 | 68 | # Contributions and Suggestions Welcome! 69 | Have something you think this needs or could use as an improvement, let me know. add [an issue on github](https://github.com/Pushplaybang/wordpress-docker-local-environment/issues) or fork and create a pull request. 70 | 71 | 72 | ____ 73 | 74 | 75 | ### License [MIT](https://opensource.org/licenses/MIT) 76 | Copyright (c) 2016 Paul van Zyl 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to deal 80 | in the Software without restriction, including without limitation the rights 81 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 82 | copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in 86 | all copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 93 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 94 | THE SOFTWARE. 95 | --------------------------------------------------------------------------------