gatsbyjs / gatsby-docker

Docker image that builds and hosts a Gatsby site
MIT License
357 stars 88 forks source link

how to use onbuild? #20

Closed laurenskling closed 5 years ago

laurenskling commented 5 years ago

If I follow the documentation, I create a Dockerfile containing:

FROM gatsbyjs/gatsby:onbuild
RUN gatsby build

This will will output:

Sending build context to Docker daemon  198.1MB
Step 1/2 : FROM gatsbyjs/gatsby:onbuild
# Executing 1 build trigger
 ---> e5cc71f754ba
Step 2/2 : RUN gatsby build
 ---> Running in 18b3c4f0d471
/bin/sh: gatsby: not found
The command '/bin/sh -c gatsby build' returned a non-zero code: 127

what am I doing wrong? How to set up a correct Dockerfile for building?

aslafy-z commented 5 years ago

As stated in the README#usage you have to bundle your aready built gastby assets into the docker image.

  1. Run locally gatsby build
  2. Create a dockerfile wich contains this (and only this):
    FROM gatsbyjs/gatsby:onbuild
  3. Build the image: docker run --rm -p 80:80 myproject/website .