Skip to content

Commit

Permalink
Add GraphQL Voyager Docker Image
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-klein authored and Its-Alex committed Nov 27, 2019
1 parent 3c1c382 commit ab1efcf
Show file tree
Hide file tree
Showing 8 changed files with 490 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
docs/
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,17 @@ app.use(router.allowedMethods());
app.listen(3001);
```

## Build Docker Image

```
$ npm install
$ npm run build:release
```

```
$ docker build . -f docker-image/Dockerfile -t apisguru/graphql-voyager
$ docker push apisguru/graphql-voyager
```

## Credits
This tool is inspired by [graphql-visualizer](https://github.com/NathanRSmith/graphql-visualizer) project.
26 changes: 26 additions & 0 deletions docker-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:11.14.0-alpine

RUN apk add \
ca-certificates \
musl-dev

ADD dist/ /graphql-voyager/dist/
ADD middleware/ /graphql-voyager/middleware/
ADD src/ /graphql-voyager/src/
ADD package.json /graphql-voyager/package.json
ADD docker-image/package.json /graphql-voyager/docker-image/package.json
ADD docker-image/package-lock.json /graphql-voyager/docker-image/package-lock.json

RUN npm install

ADD docker-image/index.js /graphql-voyager/docker-image/index.js

WORKDIR /graphql-voyager/

WORKDIR /graphql-voyager/docker-image/

RUN npm install

ENV PORT=3001

CMD node index.js
22 changes: 22 additions & 0 deletions docker-image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const express = require('express');
const voyager = require('graphql-voyager/middleware');

const app = express();

app.use('/', voyager.express({ endpointUrl: process.env.GRAPHQL_ENDPOINT }));

process.on('SIGINT', function () {
console.log("\nGracefully shutting down from SIGINT (Ctrl-C)");
process.exit(1);
});

const port = process.env.PORT;

app.listen(port, function(err) {
if (err) {
throw new Error(
`Failed to start listening on ${port}, error: ${err.message}`
);
}
console.log(`listening on http://0.0.0.0:${port}`);
});
Loading

0 comments on commit ab1efcf

Please sign in to comment.