Here is an example configuration we use for testing while developing Gatsby Shopify Storefront - lightning-fast Progressive Web App (PWA) storefront for Shopify.
A Dockerfile:
FROM node:13
WORKDIR /usr/src/app
COPY package.json .
RUN yarn global add gatsby-cli
RUN yarn install
COPY gatsby-config.js .
# Optionally, copy your .env file to the container filesystem
COPY .env .
EXPOSE 8000
CMD ["gatsby", "develop", "-H", "0.0.0.0"]
Though it is not the case with our setup, you might need to copy your project files to the container as well. Use COPY . . command for this.
Build your image:
docker build . -t gatsbystorefront:1.0.1
Run your container:
docker run -d -p 8000:8000 --name store gatsbystorefront:1.0.1
Though this one is short. Hope it will help, cheers! π π
Latest comments (4)
Any particular reason for using gatsby develop instead of gatsby build?
Why are you using
developfor production? It's justgatsby buildand you can serve it with nginx.In particular
-H 0.0.0.0is very much required. Thanks! - stackoverflow.com/a/53195417/4486804"Though it is not the case with our setup..." - alas, this is exactly the missing link for me :) I do not know how I can run the develop mode with the process running in the docker, but the Gatsby site being modifiable on my Computer...