Skip to content

Commit 383c6c2

Browse files
author
Bruno Krebs
committed
adding Docker instructions to the backend;
1 parent 95866b4 commit 383c6c2

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

backend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

backend/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# reference: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
2+
FROM node:10.13
3+
4+
# Create app directory
5+
WORKDIR /usr/src/app
6+
7+
# Install app dependencies
8+
# A wildcard is used to ensure both package.json AND package-lock.json are copied
9+
# where available (npm@5+)
10+
COPY package*.json ./
11+
12+
RUN npm install
13+
# If you are building your code for production
14+
# RUN npm install --only=production
15+
16+
# Bundle app source
17+
COPY . .
18+
19+
EXPOSE 8081
20+
CMD [ "node", "src" ]

backend/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# React Tutorial
2+
3+
[Auth0] has developed this application to support [the React Tutorial published here](https://auth0.com/blog/react-tutorial-building-and-securing-your-first-app/). Head to the article to learn about how everything works.
4+
5+
## Running the Application
6+
7+
The easiest way to run this application is to issue `node src` from a terminal pointing to this directory. This command, as you may know, requires Node.js and NPM installed locally. If you don't have those, [you can install them in a few minutes](https://nodejs.org/en/download/).
8+
9+
Another alternative is to use Docker to run the app in a container. To do so, you can issue the following commands:
10+
11+
```bash
12+
docker build -t react-tutorial-backend .
13+
14+
docker run --name react-tutorial-backend -d -p 8081:8081 react-tutorial-backend
15+
```
16+
17+
This will make your API accessible on the following URL: [`http://localhost:8081`].
18+
19+
## Releasing a new Docker Image
20+
21+
Make sure you are currently logged into Docker and then issue the following commands:
22+
23+
```bash
24+
docker build -t brunokrebs/react-tutorial-backend .
25+
26+
docker push brunokrebs/react-tutorial-backend
27+
```
28+
29+
In the code snippet above, you will need to replace `brunokrebs` with your own Docker username (unless you are me 😊).
30+
31+
If you do push a Docker image to [Docker Hub](https://hub.docker.com/), then you can use it like this:
32+
33+
```bash
34+
docker run --name react-tutorial-backend -d -p 8081:8081 brunokrebs/react-tutorial-backend
35+
```

0 commit comments

Comments
 (0)