There are 2 things you need to do to get ghost
to run in production
mode with docker
:
Add the NODE_ENV
docker run -d --name ghost -v /path/to/blog:/var/lib/ghost -e NODE_ENV=production -p 2368:2368 ghost
This is for ghost v0.11.x
. For v1.x.x
have a look at this post!
Note: If you're having trouble with the permissions on files in the volume, for example when trying to pull/add a theme, add this to the command above: -u $(id -u $USER):$(id -g $USER)
(found here)
Add a few lines to config.js
(found here)
paths: {
contentPath: path.join(process.env.GHOST_CONTENT, '/')
}
I'm also using nginx
together with Let's Encrypt, so my nginx conf looks like this:
### Redirect http requests to https
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
server_name example.com;
client_max_body_size 20M;
keepalive_timeout 10;
location ~ /.well-known {
allow all;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://0.0.0.0:2368;
proxy_redirect off;
}
}
Edit: Updated conf here