docker-library / ghost

Docker Official Image packaging for Ghost
https://hub.docker.com/_/ghost
MIT License
744 stars 314 forks source link

Additional config volume needed #36

Closed dalanmiller closed 7 years ago

dalanmiller commented 8 years ago

I'm currently trying to get Ghost working on my Kubernetes cluster.

The main problem I'm having is that I can't load config.js into the correct spot and while I can do/var/lib/ghost/content Ghost blog is expecting a lot more files than the minimum stated by the README.

So two things:

mwakerman commented 8 years ago

Yep, I just lost a few hours to the contentPath issue which was pretty frustrating.

pascalandy commented 8 years ago

Here is the notes I added on in my Dockerfile. Once you get the pattern, you're good to go!

## Good to know: ENV GHOST_SOURCE /usr/src/ghost
## Good to know: ENV GHOST_CONTENT /var/lib/ghost
## Good to know: WORKDIR $GHOST_SOURCE
## root@ec780f67ae5a:/var/lib/ghost# 
##
## The Directory structure is NOT the same as the original ghost ...
## ... there is no content directory
## apps  config.js  data  images  storage   themes
## theme are here > /var/lib/ghost/themes
##                                      not in /var/lib/ghost/content/themes
nicokaiser commented 7 years ago

This is still true for the 1.x version of the container: there is no (elegant) way to mount the "config.production.json" file – which is needed to e.g. set the base URL.

acburdine commented 7 years ago

@nicokaiser not true 😉 with ghost 1.0 comes the ability to configure your instance via environment variables - this is the intended way of doing things with ghost 1.x in Docker. See the docs for more information.

nicokaiser commented 7 years ago

@acburdine That sounds great, did not know about this!

However, it does not work. I set the "URL" environment, yet it is ignored (same if I manually run "URL=... node current/index.js" in the container). Am I missing something?

acburdine commented 7 years ago

It's a bit odd, but it needs to be a lowercased environment variable, e.g. url rather than URL

nicokaiser commented 7 years ago

Awesome, that works! Thank you @acburdine!

cowchimp commented 7 years ago

Please consider mentioning this (the option to set configuration options via the environment variables) in the Readme for the image. Many people are likely to bump into this. Thanks.

justinoverton commented 7 years ago

The docs don't specify how to configure mail settings via env.

rgarrigue commented 7 years ago

:+1: for the official ghost doc a bit lacking about mail (like gmail or custom mail). And docker's README.md missing a hints for this kind of configuration.

@justinoverton I'm was able to turn privacy on via privacy='"privacy": {"useTinfoil": true}'. I guess you can put a flat json following https://docs.ghost.org/docs/mail-config for mail config

dexafree commented 7 years ago

It's a bit odd, but it needs to be a lowercased environment variable, e.g. url rather than URL

@acburdine I used the official ghost:1.7.0-alpine image, and I tried to start a container with

docker run --rm -it \
 -p 2368:2368 \
 -e url="https://MY_URL" \
 -v /mnt/docker/ghost:/var/lib/ghost/content \
 ghost:1.7.0-alpine

If I curl https://MY_URL, it responds with a redirect to localhost:2368.

Is the env variable working only if you built the image from this dockerfile? (It would be nonsense, as I assume that the official image is the result of building this dockerfile).

It would also be nonsense having to build a dockerfile just to change this settings.

Is there something I'm missing?

Do you need to set the entrypoint/cmd manually when starting the container?

rgarrigue commented 7 years ago

@dexafree : url env worked with ghost:latest for me

Vadorequest commented 7 years ago

@dexafree Indeed, your issue is that you provided the url between double quotes. There shouldn't be any.

I'm running docker run -e url=http://eclats-de-voix.fr/ -d --name blog.eclats-de-voix-2 -p 3003:2368 -v /var/www/blog.eclats-de-voix:/var/lib/ghost/content ghost:1.12.1-alpine and it works fine. I tried first with your example (with double quotes) and it failed. ;)

alterationx10 commented 7 years ago

Just chiming in here, as I was having trouble setting up the mail variable, but figured out a bit more. As usual, the answer had been staring me in the face for the past hour!

The key line from the documentation is:

For nested config options, you'd need to separate them with two underscores:

A configuration that looks like:

"mail": { 
  "transport": "SMTP",
  "options": { 
      "service": "Mailgun",
      "auth": { 
          "user": "postmaster@ur.mailgun.com",
          "pass": "doremiabc123"
      }
  }
} 

Should have 4 independent variables set. My corresponding kubernetes deployment config would look like:

        - name: mail__transport
          value: SMTP
        - name: mail__options__service
          value: Mailgun
        - name: mail__options__auth__user
          value: postmaster@ur.mailgun.com
        - name: mail__options__auth__pass
          value: doremiabc123