Giter Site home page Giter Site logo

blog's Introduction

Run Wordpress in Docker

Source code for running my Wordpress powered blog in Docker containers

Architecture

Three containers:

  • MariaDB
  • nginx
  • FPM/Wordpress

FPM/Wordpress and nginx container shares a folder with all the Wordpress files. Any static files and Wordpress media files are served by nginx directly.

nginx container forwards requests for .php files to the FPM/Wordpress container on a UNIX socket using the FastCGI protocol.

Wordpress uses MariaDB (over another socket) for persistense of posts. Media is persisted on the Docker volume that nginx and Wordpress shares.

How to Use

Development

  1. Create volumes for Wordpress and MariaDB data.

    docker volume create blog-db-data docker volume create blog-www-html

  2. Build

    docker-compose -f docker-compose.dev.yml build

  3. Run

    docker-compose -f docker-compose.dev.yml up

Production

  1. Create volumes for Wordpress, MariaDB data and Let's Encrypt certs.

    docker volume create blog-db-data docker volume create blog-www-html docker volume create letsencrypt-certs docker volume create letsencrypt-challenge

  2. Build

    docker-compose -f docker-compose.prod.yml build

  3. Set passwords as env vars. These are substituted by Docker Compose (example is for PowerShell).

    $env:DB_PASS="YOURDBPASSWORD" $env:WP_ADMIN_PASSWORD="YOURWPPASSWORD"

  4. Initialize Wordpress. Use whatever URL is correct for your blog. API keys can be had from Akismet.

    docker-compose -f .\docker-compose.prod.yml run -e WP_API_KEY=YOUR_API_KEY -e WP_URL=localhost -e WP_ADMIN_USER=YOURUSER -e DB_PASS=$env:DB_PASS -e WP_ADMIN_EMAIL=YOUREMAIL -u www-data --entrypoint=/admin/init.sh blog

  5. Start the whole edifice

blog's People

Contributors

friism avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.