8000 Merge pull request #1 from EIrwin/master · sitepoint-editors/graphql-nodejs@2cdc271 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cdc271

Browse files
authored
Merge pull request #1 from EIrwin/master
Setup to run using Docker Compose
2 parents 9615393 + 8ad717b commit 2cdc271

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ node_modules
3232

3333
/public/
3434
dist/
35+
36+
.idea

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:6.6.0-slim
2+
MAINTAINER Eric Irwin <Eric.Irwin1124@gmail.com>
3+
4+
# Expose the default port
5+
EXPOSE 8080
6+
7+
# Create/Set the working directory
8+
RUN mkdir /app
9+
WORKDIR /app
10+
11+
COPY package.json /app/package.json
12+
RUN npm install
13+
14+
# Copy App
15+
COPY . /app
16+
17+
# Set Command
18+
CMD npm start

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
GraphQL server in Node.js using Express, MongoDB and Mongoose.
44

5+
## Running with Docker
6+
You can use `docker-compose up` to run an instance of GraphQL-MongoDB Server and MongoDB locally.
7+
8+
```bash
9+
docker-compose up
10+
```
11+
512
## Requirements
613

714
* [Node.js](http://nodejs.org/)

app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ var app = express();
99
// GraphqQL server route
1010
app.use('/graphql', graphqlHTTP(req => ({
1111
schema,
12-
pretty: true
12+
pretty: true,
13+
graphiql: true
1314
})));
1415

1516
// Connect mongo database
16-
mongoose.connect('mongodb://localhost/graphql');
17+
mongoose.connect('mongodb://mongo/graphql');
1718

1819
// start server
1920
var server = app.listen(8080, () => {

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '2'
2+
services:
3+
web:
4+
build:
5+
context: .
6+
links:
7+
- mongo
8+
ports:
9+
- "8080:8080"
10+
command: npm run start
11+
mongo:
12+
image: mongo

0 commit comments

Comments
 (0)
0