colinmeinke / ghost-storage-adapter-s3

An AWS S3 storage adapter for Ghost
Other
182 stars 86 forks source link

anyone using this on docker alpine? #49

Open Rovel opened 5 years ago

Rovel commented 5 years ago

I'm having some issues when trying to install this on docker alpine, any tips?

ghost_1  | [2019-03-26 03:16:33] ERROR
ghost_1  |
ghost_1  | We detected a misuse. Please read the stack trace.
ghost_1  |
ghost_1  | "We cannot find your adapter in: /var/lib/ghost/content/adapters/storage/ or: /var/lib/ghost/versions/2.18.3/core/server/adapters/stora
ge/"
ghost_1  |
ghost_1  | Error ID:
ghost_1  |     8e6e9310-4f75-11e9-9e4b-a961edf5f3bf
ghost_1  |
ghost_1  | Error Code:
ghost_1  |     MODULE_NOT_FOUND
ghost_1  |
ghost_1  | ----------------------------------------

ghost_1  |
ghost_1  | IncorrectUsageError: We detected a misuse. Please read the stack trace.
ghost_1  |     at new IncorrectUsageError (/var/lib/ghost/versions/2.18.3/node_modules/ghost-ignition/lib/errors/index.js:85:23)

Dockerfile:

FROM ghost:2.18.3-alpine

# Copy Ghost config.json
COPY ghost/config.production.json .

# Install S3 Pkg
RUN npm install ghost-storage-adapter-s3 && \
    mkdir -p /var/lib/ghost/content/adapters/storage/ && \
    cp -r ./node_modules/ghost-storage-adapter-s3 /var/lib/ghost/content/adapters/storage/s3 && \
    cd /var/lib/ghost/content/adapters/storage/s3 && \
    npm install && \
    npm audit fix
spmurrayzzz commented 5 years ago

@Rovel I ran into a similar issue and discovered the root cause. In the Dockerfile they specify the content/ path as a VOLUME mount point (https://github.com/docker-library/ghost/blob/master/2/alpine/Dockerfile#L59)

Removing this line fixes the issue (in my case, I just built my own image after forking)

Edit: forgot to note why this happens. Whenever a volume is declared in a Dockerfile, if any build step modifies the state of that path after the declaration occurs, then all of those changes are discarded (https://docs.docker.com/engine/reference/builder/#volume)

Rovel commented 5 years ago

So @spmurrayzzz does this works 100% since the content volume is not in the docker image, probably you will face some problems with saving configs, themes and stuff. did you?

An alternative is to run the container passing the volume path in the docker run after the image is built.

I had some doubts around the use of nginx and ssl config with ghost docker images the scripts that are built in to make this happen have no use in those docker issues, how did got around those too?

I did with AWS ALB and setting the ssl thru the ALB

spmurrayzzz commented 5 years ago

Our docker image/container is completely stateless. We run a dozen or so copies of ghost behind a load balancer, and all the content we store (imgs, etc) are synced to s3 via custom storage adapters (https://docs.ghost.org/concepts/storage-adapters/)

Rahulsharma0810 commented 4 years ago

@spmurrayzzz Can you share your working dockerfile with s3 and entrypoint.sh, I am not able to get it working even after removing your mentioned line.

spmurrayzzz commented 4 years ago

@Rahulsharma0810 I should have used the commit hash url (the file has changed over time so line numbers no longer match up). But essentially would need to remove the VOLUME declaration in the Dockerfile if you plan to make changes to that particular path.

kwyn commented 4 years ago

@spmurrayzzz is correct. I got the docker build working but once I deployed with environment variables the aws-sdk kicked back an error at me. Unfortunately it's very difficult to debug since the version for the aws-sdk is not pinned so it's unclear which version of the aws sdk I installed. I'd suggest to the author that they pin their versions especially for a library like this.