Skip to content

Commit 95866b4

Browse files
author
Bruno Krebs
committed
fixing Docker file for the React app;
1 parent e388f63 commit 95866b4

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
FROM nginx
2+
COPY nginx.conf /etc/nginx/conf.d/default.conf
23
COPY build /usr/share/nginx/html
3-

frontend/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ Another alternative is to use Docker to run the app in a container. To do so, yo
1111
```bash
1212
docker build -t react-tutorial .
1313

14-
docker run --name react-tutorial -d -p 80:80 react-tutorial
14+
docker run --name react-tutorial -d -p 3000:80 react-tutorial
1515
```
1616

17+
This will make your app accessible on the following URL: [`http://localhost:3000`].
18+
1719
## Releasing a new Docker Image
1820

1921
Make sure you are currently logged into Docker and then issue the following commands:
@@ -29,5 +31,5 @@ In the code snippet above, you will need to replace `brunokrebs` with your own D
2931
If you do push a Docker image to [Docker Hub](https://hub.docker.com/), then you can use it like this:
3032

3133
```bash
32-
docker run --name react-tutorial -d -p 80:80 brunokrebs/react-tutorial
34+
docker run --name react-tutorial -d -p 3000:3000 brunokrebs/react-tutorial
3335
```

frontend/nginx.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html;
8+
9+
# this is needed so React can handle requests
10+
# to whatever URI the browser is requesting
11+
# (e.g., /callback)
12+
try_files $uri /index.html;
13+
}
14+
}

0 commit comments

Comments
 (0)