# How to add a theme to Dockerfile

**URL:** <https://forum.ghost.org/t/how-to-add-a-theme-to-dockerfile/17876>\
**Category:** Themes\
**Created:** [October 27, 2020, 3:22pm UTC](https://forum.ghost.org/t/how-to-add-a-theme-to-dockerfile/17876 "2020-10-27T15:22:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kopax](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kopax/32/10139_2.png) [@kopax](https://forum.ghost.org/u/kopax)\
**Post date:** [October 27, 2020, 3:22pm UTC](https://forum.ghost.org/t/how-to-add-a-theme-to-dockerfile/17876/1 "2020-10-27T15:22:37Z")

</div>

Hi everyone,

I am following this toturial to create a development environment for casper and docker [Ghost & Docker : Mon environnement de développement !](https://www.grottedubarbu.fr/ghost-docker-theme-dev/)

I have two repository:

- the ghost blog
- the theme

I usually clone both in different directories and do a symlink so it’s available in my work space, this work great.

I am able to edit the forked casper theme and have the change by pressing F5.

I now want within the CI to create a docker image using a custom `Dockerfile` where I’ll add the theme in it.

Perhaps the idea is bad, how would you recommend to do that?

---

<div class="post-metadata">

**Author:** ![Jeff\_Tully](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jeff_tully/32/4355_2.png) [@Jeff\_Tully](https://forum.ghost.org/u/Jeff_Tully)\
**Post date:** [January 25, 2021, 5:42pm UTC](https://forum.ghost.org/t/how-to-add-a-theme-to-dockerfile/17876/2 "2021-01-25T17:42:17Z")

</div>

I have a Similar issue, I have a theme that is being pushed into my docker container, and it appears on the list so you can click and activate it, I would like to skip that step.

---

<div class="post-metadata">

**Author:** ![JakaC](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jakac/32/14307_2.png) [@JakaC](https://forum.ghost.org/u/JakaC)\
**Post date:** [July 26, 2021, 12:54pm UTC](https://forum.ghost.org/t/how-to-add-a-theme-to-dockerfile/17876/3 "2021-07-26T12:54:09Z")

</div>

To set the active theme modify theme.active\_theme in core/server/data/schema/default-settings.json  
There’s all sorts of goodies to set there so I made a modified version and added a COPY statement to my Dockerfile that overwrites the existing one.

---

<div class="post-metadata">

**Author:** ![james.kerber](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@james.kerber](https://forum.ghost.org/u/james.kerber)\
**Post date:** [November 22, 2022, 4:43pm UTC](https://forum.ghost.org/t/how-to-add-a-theme-to-dockerfile/17876/4 "2022-11-22T16:43:41Z")

</div>

This is the complete solution for those wondering:

```auto
FROM ghost:alpine

ARG NAME

# Copy theme files
COPY dist/$NAME.zip /var/lib/ghost/content.orig/themes/$NAME.zip
RUN cd /var/lib/ghost/content.orig/themes && \
    unzip $NAME.zip -d $NAME && rm -rf $NAME.zip && \
    # Set theme to active
    (sed -i "s/casper/$NAME/" /var/lib/ghost/versions/$GHOST_VERSION/core/server/data/schema/default-settings.json || sed -i "s/casper/$NAME/" /var/lib/ghost/versions/$GHOST_VERSION/core/server/data/schema/default-settings/default-settings.json) && \ 
    # Install routes.yaml
    mv ./$NAME/routes.yaml ../settings/routes.yaml

```

That last line is a little extra, my theme also defines custom routing.

If you see two `sed` commands, it’s because some versions have the default-settings.json in a different location; both are included as a failsafe.

A very nice side-effect of this is that if you’re running Ghost on Docker/K8s and you have the S3 adapter installed, you don’t need a persistent volume anymore
