https://github.com/rifandani/backend-template-graphql
Backend GraphQL template with graphql-yoga + typescript + eslint + jest + postgres + prisma
https://github.com/rifandani/backend-template-graphql
apollo-server-express docker eslint graphql jest postgresql prisma2 typescript
Last synced: 2 months ago
JSON representation
Backend GraphQL template with graphql-yoga + typescript + eslint + jest + postgres + prisma
- Host: GitHub
- URL: https://github.com/rifandani/backend-template-graphql
- Owner: rifandani
- Created: 2021-02-03T14:04:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T15:37:29.000Z (about 5 years ago)
- Last Synced: 2025-08-26T06:40:17.286Z (10 months ago)
- Topics: apollo-server-express, docker, eslint, graphql, jest, postgresql, prisma2, typescript
- Language: TypeScript
- Homepage: https://github.com/prisma-labs/graphql-yoga
- Size: 170 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js with Docker
> from [Nodejs official website](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/)
## Building your image
Go to the directory that has your `Dockerfile` and run the following command to build the Docker image.
The `-t` flag lets you tag your image so it's easier to find later using the docker images command:
```bash
docker build -t /node-web-app .
```
Your image will now be listed by Docker:
```bash
$ docker images
REPOSITORY TAG ID CREATED
node 14 1934b0b038d1 5 days ago
/node-web-app latest d64d3505b0d2 1 minute ago
```
## Run the image
Running your image with `-d` runs the container in detached mode, leaving the container running in the background.
The `-p` flag redirects a public port to a private port inside the container. Run the image you previously built:
```bash
docker run -p 49160:8080 -d /node-web-app
```
Print the output of your app:
```bash
# Get container ID
$ docker ps
# Print app output
$ docker logs
# Example
Running on http://localhost:8080
```
If you need to go inside the container you can use the `exec` command:
```bash
# Enter the container
$ docker exec -it /bin/bash
```
## Test
To test your app, get the port of your app that Docker mapped:
```bash
$ docker ps
# Example
ID IMAGE COMMAND ... PORTS
ecce33b30ebf /node-web-app:latest npm start ... 49160->8080
```
In the example above, Docker mapped the `8080` port inside of the container to the port `49160` on your machine.
Now you can call your app using `curl` (install if needed via: `sudo apt-get install curl`):
```bash
$ curl -i localhost:49160
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 12
ETag: W/"c-M6tWOb/Y57lesdjQuHeB1P/qTV0"
Date: Mon, 13 Nov 2017 20:53:59 GMT
Connection: keep-alive
Hello world
```