Skip to content

Ensure casper theme is always in content directory#26

Closed
adam-beck wants to merge 1 commit intodocker-library:masterfrom
adam-beck:master
Closed

Ensure casper theme is always in content directory#26
adam-beck wants to merge 1 commit intodocker-library:masterfrom
adam-beck:master

Conversation

@adam-beck
Copy link

When working on an individual theme, simply mounting the /var/lib/ghost/themes/$THEME_NAME directory will not suffice. Casper needs to be in this directory for Ghost to start so it only makes sense that it is guaranteed to be there.

@tianon
Copy link
Member

tianon commented Jan 22, 2016

Ah, this is an unpleasant side effect of #8. 😞

I'm not thrilled about the idea of hard-coding casper here (since that kind of hard-coding has already bitten us as seen in #8), but maybe expanding that loop to check $GHOST_SOURCE/content/themes/* additionally would work (to ensure all default themes are copied, even if we have themes)? This does make the default theme undeletable, but it sounds like it existing is already an assumption that Ghost itself has.

diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 24c8e45..ec7842f 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -2,8 +2,9 @@
 set -e

 if [[ "$*" == npm*start* ]]; then
-   for dir in "$GHOST_SOURCE/content"/*/; do
-       targetDir="$GHOST_CONTENT/$(basename "$dir")"
+   baseDir="$GHOST_SOURCE/content"
+   for dir in "$baseDir"/*/ "$baseDir"/themes/*/; do
+       targetDir="$GHOST_CONTENT/${dir#$baseDir/}"
        mkdir -p "$targetDir"
        if [ -z "$(ls -A "$targetDir")" ]; then
            tar -c --one-file-system -C "$dir" . | tar xC "$targetDir"

@adam-beck
Copy link
Author

I'll take a look at this. I'm not 100% sure that Ghost has the expectation that the Casper theme is present. Maybe there is an environment variable or configuration setting that allows you to supply a default theme on startup.

@adam-beck
Copy link
Author

It looks like the database would need to be modified to tell Ghost which theme to start with. I don't think that would be a wise decision. So I will take another look at the code comments you made.

@tianon Although I still don't understand why this approach I suggested isn't viable. Without casper, Ghost will break. I think it makes sense to directly copy that in.

@adam-beck
Copy link
Author

@tianon I don't see any other way around hardcoding the copying of the casper theme into the $GHOST_CONTENT/theme directory. This is entered into Ghost's database as the default theme. And if we use your recommended changes to this commit we are still not being defensive. For instance, if they change the name of the themes folder to something else. Yes, it could potentially break with future releases of Ghost but only if they don't make things backwards compatible. At that point I don't think it's unreasonable to re-write the script to match any changed API/folder structure.

@adam-beck
Copy link
Author

Any other suggestions to get this moving?

@tianon
Copy link
Member

tianon commented Feb 29, 2016

@adam-beck the patch I posted is essentially just a more generic version of your patch (such that if the pre-supplied theme name ever changes, the script will not need to be updated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants