Giter VIP home page Giter VIP logo

wordpress-swarm's Introduction

wordpress-swarm

This file structure helps noobs like me to fast deploy locally a wordpress container within docker swarm.

What do you need:

  1. A unix like system to run the magic stuff (bash script)
  2. Docker installed on your system (just follow the docker documentation)
  3. Docker compose
  4. Docker swarm activated to use docker secret

How to use - fresh wordpress installation

  1. Change the SERVICE_NAME in files deploy.sh and manage.sh for wathever you want.

  2. Create a docker secret password. Run on terminal:

    printf "password" | docker secret create wp_db_password -
    
  3. Create a docker secret username. Run on terminal:

    printf "username" | docker secret create wp_db_username -
    

Hint: Save your credentials. I am already forgot them and needed to redo everything...

  1. Change "db ports", "wordpress ports" and "adminer ports" on docker-compose.yml for whathever you want.
  2. Inside the project folder run on terminal:
    ./deploy.sh
    

Attention The depends_on is not working anymore within docker swarm. Sometimes the db services takes time to up properly and therefore the wordpress page shows "Database error connection" message. You can either wait until db container is online or restart the wordpress container.

If you need to move your stuffs between servers

On the old server:

The script creates a .tar.gz file with your wp-content folder and MySQL wordpress database. Just run:

./manage.sh backup password

Where the password is the password you set with docker secret.

The script creates a backup folder inside the project folder with your-service-name.tar.gz compressed file.

On the new server:

  1. Clone the repo on your new server and create a folder backups inside it.

  2. Transfer the your-service-name.tar.gz file from the old server to the folder you just created on the new server.

  3. Create a docker secret password. It must be the same you set on the old server:

    printf "password" | docker secret create wp_db_password
    
  4. Create a docker secret username. It must be the same you set on the old server::

    printf "username" | docker secret create wp_db_username
    
  5. Load the backup files into wordpress and db services:

    ./manager.sh username password
    

Where username and password are the same you set on docker secret (they must be the same since you are using the same project)

You should be able to access your wordpress page with all customizations and posts.

If you want to delete everything related to the service.

Just run:

./manage.sh down
./manage.sh remove-volumes

You can run ./manage.sh down remove-volumes but I recommend to wait a bit before run ./manage.sh remove-volumes since ./manage.sh down takes times to properly remove services. If you face any error related to the volumes being used by services run the ./manage.sh remove-volumes again.

Things to fix/improve

  • Auto backup folder creation.
  • Trigger wordpress service on docker-compose after db service healthcheck
  • Implement a rountine to check if ./manage.sh down is completed before rurn ./manage.sh remove-volumes

wordpress-swarm's People

Contributors

mutgarth avatar

Watchers

 avatar

Forkers

heartshare

wordpress-swarm's Issues

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.