version: '3.7'
# It makes sure all containers share one network so they can connect to each other (Ghost connects to a database).
services:
ghost:
image: ghost:alpine
container_name: ghost
# This will make sure the container is started after the server reboots.
restart: always
depends_on:
- db
# This will make Ghost accessible outside on port 8080.
ports:
- 8080:2368
# This will store all uploaded images in a dedicated volume that survives a restart.
volumes:
- ghost-content:/var/lib/ghost/content
environment:
# Configuring Ghost with env variables.
# https://docs.ghost.org/v1/docs/config#section-running-ghost-with-config-env-variables
# It might be desired to configure also a mail service.
url: "https://example.com"
database__client: mysql
database__connection__host: db
database__connection__user: root
database__connection__password: changeme
database__connection__database: ghost
# A host used by nginx-proxy. You can also list variants with www if desired.
VIRTUAL_HOST: "example.com"
LETSENCRYPT_HOST: "example.com"
LETSENCRYPT_EMAIL: "[email protected]"
db:
image: mysql
container_name: mysql-ghost
restart: always
environment:
MYSQL_ROOT_PASSWORD: changeme
volumes:
- ghost-mysql:/var/lib/mysql
# It makes sure Ghost is accessible from your-domain.com.
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
restart: always
ports:
- 80:80
- 443:443
volumes:
- conf:/etc/nginx/conf.d
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- certs:/etc/nginx/certs:ro
- dhparam:/etc/nginx/dhparam
- /var/run/docker.sock:/tmp/docker.sock:ro
# It makes this container discoverable by the companion container.
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
# It fetches and manages certificates and necessary configuration for SSL.
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-proxy-le
restart: always
depends_on:
- nginx-proxy
volumes:
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- certs:/etc/nginx/certs
- dhparam:/etc/nginx/dhparam:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
# All used volumes need to be defined.
volumes:
ghost-content:
ghost-mysql:
conf:
vhost:
html:
certs:
dhparam:
put on docker volume
xxx_conf
client_max_body_size 30m;
save as custom-nginx.conf