Quick start docker compose that include Ghost blog, Nginx proxy with TLS/SSL and MySQL database. The intention is to get a general feel of depolying Ghost in production mode, where each component (Web, App & DB) are deployed seperately. This supports scaling and isolate failure (if any).
If you want to test Ghost in dev mode, you can run docker compose -f ./dev/docker-compose.dev.yml
or use the Ghost CLI.
npm install -g ghost-cli@latest # Install Ghost
ghost install local # Running on Dev
- Opearting Env
- Technolgoy Stack
- Preparation
- How to use it
- Database Backup
- Install Customised Theme
- Security and Networking
- License
- References
☝️ Easy setup
👨💻 Ready to production and local development
⚡ Performance Optimized
🔒 SSL auto-renewed
-
Operating System Ubuntu is the default OS. Use 20.04 or newer.
-
docker Docker version 20.10.23, build 7155243.
-
docker-compose Docker Compose version v2.15.1.
- Node.js
- Ghost blog software version 5.x (defaults to latest version).
- NGINX
- proxying port 80 calls to the Node web server on port 2368.
- MySQL database
- version 8.0.
- using
UTFMB4encoding (UTF8, actually). MySQL's UTF8 implementation is limited. UTFMB4 includes Emoji, try using it.
- A server sitting somewhere, like Amazon EC2 , Google Compute Cloud or a virutal machine (VPS) connected to your own network.
- Register a domain name (either public or within your own network).
- Access to your domain's DNS.
- Make sure your DNS domain points to your host machine.
- Clone this project into the server's filesystem.
- And .env file with the following variables:
GHOST_APP_DOMAIN=yourdomain.com
ROOT_PSD=rootpswrd
MYSQL_DATABASE=ghostdb
MYSQL_DATABASE_USER=ghost
MYSQL_PASSWORD=mysqlpswd
ENVIRONMENT=production
EMAIL_ADDRESS=mail@yourdomain.com
- Edit settings in config.<>.json and docker-compose.yml as necessary and only if you wish, as it is not required.
- config.production.json and update the fields as required
- Database Initial set-up settings - under ghost and mysql services in docker-compose file, indicate the env variables
- Run
cd docker-compose-ghost-quickstart && sudo chmod +rwx setup.sh
. - Execute the setup script.
./setup.sh
.
In your local environment you need to have installed:
- Docker
- Docker Compose
After clone this repository, you can access the dev
folder to be able to run the local dev environment using this command below.
git clone https://github.com/clean-docker/ghost-cms.git ghost
cd ghost/dev
docker-compose up -d
Done! Access your https://localhost/ghost to access the admin panel and create your account.
- Run "docker-compose ps" to get a list of running containers.
- Locate the name of the mysql container.
- Run this command to get the container's internal IP: docker inspect --format='{{.NetworkSettings.IPAddress}}' THAT_CONTAINER-NAME
- In your favorite database GUI tool (like Navicat or DataGrip), create a new connection via SSH tunnel to the host machine
- Use the internal IP address and database user and password to connect to database once SSH tunnel is established to host.
- You'll have access to the data so you can view data and run backups.
Stop docker-compose with:
docker-compose stop
Copy the new theme to ./ghost/content/theme so that your theme folder sits next to the casper folder in the themes directory
Now run:
docker-compose up -d
Log in to the Ghost admin, go to Settings > General, and at the bottom is the Theme dropdown. Select your theme and click Save.
How does that work?
The ./ghost/content directory (on docker host machine) gets mounted inside your ghost container folder /var/lib/ghost when the container starts running. See docker-compose.yml for more details
- Only NGINX's ports (443) are exposed at host level.
- Support only TLS version 1.2 for incoming traffic
- HTTP/2 Enabled for Nginx Reverse Proxy
- Docker Compose for Ghost by John Washam
- Ghost@Dockerhub
- Installing Ghost locally for Dev
- How to host Ghost on Docker
- Nginx and Let’s Encrypt with Docker in Less Than 5 Minutes
- Ghost CMS + Docker Compose
Commands | Description |
---|---|
./scripts/dc start |
Start your containers |
./scripts/dc stop |
Stop all containers |
./scripts/dc update |
Get Ghost updates and restart containers |