-
Notifications
You must be signed in to change notification settings - Fork 733
Initial docker image #911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Initial docker image #911
Changes from all commits
98fb959
66de03c
7700574
4a95fc7
67cfd83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# dependencies | ||
node_modules | ||
example/node_modules | ||
**/node_modules | ||
example/yarn.lock | ||
|
||
# testing | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:alpine | ||
|
||
RUN mkdir /app | ||
COPY server/index.js /app | ||
COPY server/package.json /app | ||
|
||
WORKDIR /app | ||
RUN yarn | ||
|
||
ENV GRAPHQLPLAYGROUND_PORT 8080 | ||
ENV GRAPHQLPLAYGROUND_HOST "http://localhost:3000/graphql" | ||
ENV GRAPHQLPLAYGROUND_TITLE "GraphQL Playground" | ||
|
||
EXPOSE 8080 | ||
CMD [ "node", "index.js" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const express = require('express') | ||
|
||
const defaults = { | ||
port: 8080, | ||
host: 'http://localhost:3000/graphql', | ||
title: 'GraphQL Playground' | ||
} | ||
|
||
const port = +process.env.GRAPHQLPLAYGROUND_PORT || defaults.port | ||
const host = process.env.GRAPHQLPLAYGROUND_HOST || defaults.host | ||
const title = process.env.GRAPHQLPLAYGROUND_TITLE || defaults.title | ||
|
||
const app = express() | ||
|
||
const html = ` | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset=utf-8/> | ||
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui"> | ||
<title>${title}</title> | ||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/graphql-playground-react/build/static/css/index.css" /> | ||
<link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react/build/favicon.png" /> | ||
<script src="//cdn.jsdelivr.net/npm/graphql-playground-react/build/static/js/middleware.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't those come from the image ? (if I'm running graphql-playground in docker I expect it to work even without internet connection) |
||
</head> | ||
|
||
<body> | ||
<div id="root"> | ||
<style> | ||
body { | ||
background-color: rgb(23, 42, 58); | ||
font-family: Open Sans, sans-serif; | ||
height: 90vh; | ||
} | ||
|
||
#root { | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.loading { | ||
font-size: 32px; | ||
font-weight: 200; | ||
color: rgba(255, 255, 255, .6); | ||
margin-left: 20px; | ||
} | ||
|
||
img { | ||
width: 78px; | ||
height: 78px; | ||
} | ||
|
||
.title { | ||
font-weight: 400; | ||
} | ||
</style> | ||
<img src='//cdn.jsdelivr.net/npm/graphql-playground-react/build/logo.png' alt=''> | ||
<div class="loading"> Loading | ||
<span class="title">GraphQL Playground</span> | ||
</div> | ||
</div> | ||
<script>window.addEventListener('load', function (event) { | ||
GraphQLPlayground.init(document.getElementById('root'), { | ||
endpoint: "${host}" | ||
}) | ||
})</script> | ||
</body> | ||
|
||
</html> | ||
` | ||
|
||
app.get('/', (req, res) => res.send(html)) | ||
|
||
app.listen(port, function(error) { | ||
if (error) console.error(error) | ||
console.log( | ||
`GraphQL Host set to ${host} ${ | ||
host === defaults.host ? '(Default)' : '' | ||
}`, | ||
`\n\nServing the GraphQL Playground on http://localhost:${port}/playground ${ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it only listen on 127.0.0.1 ? if not be default there should be an option to make it listen on 0.0.0.0 or something else (so that it works with a reverse proxy) |
||
port === defaults.port ? '(Default)' : '' | ||
}` | ||
) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "server", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.16.4" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
GRAPHQLPLAYGROUND_API_ENDPOINT
orGRAPHQLPLAYGROUND_ENDPOINT