Skip to content

Instantly share code, notes, and snippets.

@araphiel
Last active January 17, 2019 19:14
Show Gist options
  • Save araphiel/3ab68a6e3eb4843b0c746cba0bd9732f to your computer and use it in GitHub Desktop.
Save araphiel/3ab68a6e3eb4843b0c746cba0bd9732f to your computer and use it in GitHub Desktop.
Gatsby.js Docker
GATSBY_WEBPACK_PUBLICPATH=/
ENABLE_REFRESH_ENDPOINT=true
FROM node:10.15 as builder
WORKDIR /app
COPY . .
RUN npm install
FROM node:10.15-alpine
WORKDIR /app
COPY --from=builder app .
EXPOSE 8000
CMD ["npm", "run", "dev", "--", "-H", "0.0.0.0"]
{
"AWSEBDockerrunVersion": 1,
"Ports": [
{
"ContainerPort": 8000,
"HostPort": 8000
}
]
}
@araphiel
Copy link
Author

A basic setup for running your Gatsby.js project in Docker.
Run this in the cloud & you effectively have a working Gatsby preview server.

Once it's up - all you need to do is send a POST request to https://yourpreviewdomain.com/__refresh to see your data update live.

Really useful if you're using a datasource like Contentful or Wordpress.

Also included is a Dockerrun.aws.json file, in case you want to use this with Elastic Beanstalk.

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