Step 1. get
now CLI tool, if you haven't already, by visiting the Downloads page, and installing the Now app to your computer.
Step 2. clone
Clone the official
ghost Docker library repository:
$ git clone git://github.com/docker-library/ghost.git Cloning into 'ghost'... remote: Counting objects: 160, done. remote: Compressing objects: 100% (6/6), done. remote: Total 160 (delta 1), reused 0 (delta 0), pack-reused 154 Receiving objects: 100% (160/160), 27.76 KiB | 0 bytes/s, done. Resolving deltas: 100% (77/77), done.
Step 3. config
ghost uses a local sqlite3 database for storage. This works fine, but will not persist throughout multiple deployments (i.e. as newer versions of ghost become available). You can instead use a cloud hosted MySQL database by providing your own
config.js file for ghost.
Dockerfile to copy in your config.js file into the container's
$GHOST_CONTENT directory. You may also specify which "env" for ghost to use by assigning
NODE_ENV variable to one matching inside the config.js file ("development" is the default):
$ cd ghost $ git diff diff --git a/Dockerfile b/Dockerfile index b1176cc..e427470 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,9 @@ ENV GHOST_CONTENT /var/lib/ghost RUN mkdir -p "$GHOST_CONTENT" && chown -R user:user "$GHOST_CONTENT" VOLUME $GHOST_CONTENT +ENV NODE_ENV production +COPY config.js "$GHOST_CONTENT/config.js" + COPY docker-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"]
We also need a
config.js file to use. I've prepared a stripped down version of the
config-example.js file that has some good defaults for deploying to now.sh:
$ curl -L https://git.io/vPCyV > config.js
Use your favorite text editor to change the
database, etc., config settings.
Step 4. deploy
Last step is to deploy to now. In typical fashion, a single command with no arguments does everything that we want.
$ now > Deploying ~/ghost > No `name` LABEL in `Dockerfile`, using ghost > Ready! https://ghost-abcnwhjzxy.now.sh (copied to clipboard) [1s] > Initializing…
Wait a minute or two for the deployment to complete, then the URL that has been copied to your clipboard should fire up your ghost deployment in a web browser!
Step 5. alias
The final step is to alias the new ghost blog to the URL specified in your
config.js file. So for example, to alias the ghost deployment that you are reading now to https://n8.io, I ran:
$ now alias set ghost-krjpyhytqq.now.sh n8.io > n8.io is a custom domain. > Verifying the DNS settings for n8.io (see https://zeit.world for help) > Verification OK! > Success! Alias created (ABCCAwOwoYnMdt0A2APPUXyZ): https://n8.io now points to https://ghost-krjpyhytqq.now.sh (aBCMRT3LQqqS4X33QMYDJxyz)
Aliasing depends on Zeit's DNS servers being properly configured for your domain.
Thanks for reading. Happy Zeit'ing!