Open mschipperheyn opened 4 years ago
Ok, I figured it out. Here's what you do.
Create a Dockerfile
FROM mhart/alpine-node:12
WORKDIR /usr/src/app
COPY ./src/apollo/remote/my-schema.sdl /usr/src/app
RUN npm install -g graphql-faker
EXPOSE 9002
CMD graphql-faker ./my-schema.sdl
Login to heroku on the command line
heroku container:login
We are now going to run the image locally and push it to heroku.
docker build .
# run locally and test that it works
docker run -d -p 9002:9002 <IMAGEID>
docker tag <IMAGEID> registry.heroku.com/<HEROKU PROJECT NAME>/web
docker push registry.heroku.com/<HEROKU PROJECT NAME>/web
heroku ps:scale web=1
And you're live at HEROKU PROJECT NAME.herokuapp.com/graphql
@IvanGoncharov recommend adding this to the docs.
@mschipperheyn Thanks for investigation, we should definitely include this into README 👍 Do you want to work on PR to add it?
FROM mhart/alpine-node:12
Can you use our official docker image as a base: https://hub.docker.com/r/apisguru/graphql-faker
That way you can cut a couple lines from your Dockerfile and have a faster build.
@IvanGoncharov Sure
Hello All, I tried the "docker" route and did not have much luck. Mainly because I'm not up-to-speed with docker.
What did work for me was simply deploying an NPM project to my Heroku application and Heroku detects that it's an NPM app, performs the install of graphql-faker and runs the graphql-faker run command.
Here are the steps: 1) create a directory to store your graphql-faker-deployment project 2) create package.json file with these contents.
{
"name": "graphql-faker-deploy",
"version": "0.0.1",
"description": "",
"dependencies": {
"graphql-faker": "^2.0.0-rc.23"
},
"devDependencies": {},
"scripts": {
"start": "graphql-faker -p ${PORT:=9002} --forward-headers Authorization --extend {URL_TO_YOUR_GRAPHQ_ ENDPOINT} ./temp.faker.graphql"
},
"author": "",
"license": "ISC"
}
-- Now follow the standard Heroku deployment flow (re: https://devcenter.heroku.com/articles/deploying-nodejs)
3) Git init the project directory 4) Commit the files 4) Set remote named 'heroku' to git URI of your Heroku app 5) Git push to Heroku remote
Not an expert on Docker.
I managed to deploy graphql-faker to Heroku
where APPNAME is the heroku app name and IMAGEID is the local graphql-faker Docker image you created with
docker-compose up -d
.docker-compose.yml
However, my issue is deploying the sdl schema along with the image. Bc it's currently referenced locally for development but the image deploy doesn't include the schema and hence I get the default schema on Heroku.