Setting Environmental Variables for a Ghost Docker Container in Reclaim Cloud

If the title hasn’t scared you away, then welcome!

Image of a rainy, dark tree

Rainy Dark Tree from PxHere

Over the weekend I was struggling to get a mapped URL for a Ghost container on Reclaim Cloud resolving consistently to the main URL. While the home page worked, several subpages were defaulting to localhost:2386, which is hardcoded in the config.production.json file.* This is where that URL is normally defined, but Docker environmental variables are not actually read through this file, which is a bit of abstraction you have to wrap your head around when working with Docker. That file will work consistently if it’s hosted on a stack, but in a Docker container you need an environmental variable file (or .env file). Another detail discovered on my journey towards understanding Docker. Thankfully I have Taylor Jadin to think this stuff through with now given he’s a bit further ahead in his grasp of containers and has played with Reclaim Cloud a fair bit.

So, the proper way to deal with this issue in Reclaim Cloud is to add the url variable to the container environment. In the Ghost application container go to Additional Settings –> Variables:

Accessing Variables menu on a Reclaim Cloud container

Accessing Variables menu on a Reclaim Cloud container

From there click on the green Add button:

Image of Add button and Ghost variables

Add button and pre-existing Ghost container variables

After that you need to add the url variable as illustrated below (keep in mind url needs to be lowercase):

Adding Ghost url variable

Adding Ghost url variable in application container

This will ensure your environment loads cleanly over a mapped domain, and all references to the domain url are updated throughout the container. Be sure to restart the application container (not the load balancer) and give it a minute or so and the site will come back up.

This solution helped me stop using the hack of cloning the site with an edited url field in the config.production.json file to fix the issue, while also solving my adjacent issue with setting the Newsletter/Support emails. I’ll write more on that in my next post about Setting Up Email for a Ghost Newsletter.

Ghost mail__from variable

Adding Ghost’s mail__from variable in Reclaim Cloud

Another variable I added to my Ghost container was mail__from -you can see an example of this above for the address ghost_at_bavatuesdays.com.
________________________

*This file is found in the var/lib/ghost/ directory of the official Ghost Docker image.

This entry was posted in Ghost, Reclaim Cloud and tagged , , . Bookmark the permalink.

7 Responses to Setting Environmental Variables for a Ghost Docker Container in Reclaim Cloud

  1. Taylor Jadin says:

    ???

    I think we may want to eventually do a take 2 on the installing Ghost on Reclaim Cloud video, informed by what we learn with the newsletter over time. Installing ghost using the official docker container uses so much fewer resources than the Marketplace installer that once we know we have a good understanding of all the little facets (installing, upgrading over time etc.) I think I’d suggest most people go the Docker route.

    • Taylor Jadin says:

      Oh no my emojii show up as question marks! those are supposed to be thumbs up emojii!

      • Reverend says:

        I’ll thumbs up you commenting here, and I agree with you on Docker, it seems the way to go long term given the old app stack I installed last year on Reclaim Cloud is not really tenable with no clear way to upgrade anymore. And with my recent struggles with Mattermost from the marketplace, I am re-thinking some of that more generally.

        I am definitely game for a redo on the guide for installing Docker given it has been an awesome occasion to figure some of this out.

  2. Pingback: Configuring Email for a Ghost Docker Container on Reclaim Cloud | bavatuesdays

  3. Pingback: bavaweekly 1-18-2022 | bavatuesdays

  4. Aliya says:

    Hi, How do I configure SMTP details for mailgun using environment variables?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.