Skip to content

Commit b47afa0

Browse files
authored
Merge pull request #111 from LuCEresearchlab/deployment-fixes
Deployment fixes
2 parents 6e0645b + f51cc3b commit b47afa0

27 files changed

+78
-39
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ this will allow for a more scalable tagging experience.
1414
- mongodb: Dockerfile for MongoDB server
1515
- tagging service: Python Flask server
1616

17-
1817
## Usage
18+
1919
The application is entirely dockerized and as such can be run as long as Docker is installed, to run it:
20+
2021
```
2122
cd python-react-tagging-standalone
2223
docker-compose up -d # development
2324
docker-compose -f docker-compose-deploy.yml up -d # deployment
2425
```
26+
2527
then connect to http://localhost:8080/
2628

29+
In the case of deploying the application it is required to set
30+
`TAGGING_SERVICE_URL=<host-url>:5000` inside the file `frontend/.env.prod`.
31+
2732
To stop the containers
2833

2934
```

frontend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
**/node_modules
2+
build
3+
logs

frontend/.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
NODE_PATH=./
2-
TAGGING_SERVICE_URL=http://localhost:5000

frontend/.env.prod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TAGGING_SERVICE_URL=http://192.168.1.169:5000

frontend/Dockerfile-deploy

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:15.14.0-alpine3.10
1+
FROM node:15.14.0-alpine3.10 as build
22

33
EXPOSE 8080
44

@@ -10,4 +10,19 @@ RUN npm ci
1010

1111
RUN npm run build
1212

13-
CMD ["node", "server.js"]
13+
FROM nginx:alpine
14+
15+
# copy the build folder from react to the root of nginx (www)
16+
COPY --from=build /app/build /usr/share/nginx/html
17+
18+
# --------- only for those using react router ----------
19+
# if you are using react router
20+
# you need to overwrite the default nginx configurations
21+
# remove default nginx configuration file
22+
RUN rm /etc/nginx/conf.d/default.conf
23+
# replace with custom one
24+
COPY nginx/nginx.conf /etc/nginx/conf.d
25+
26+
EXPOSE 8080
27+
28+
CMD ["nginx", "-g", "daemon off;"]

frontend/config.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

frontend/nginx/nginx.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
3+
listen 8080;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
try_files $uri $uri/ /index.html;
9+
}
10+
11+
12+
error_page 500 502 503 504 /50x.html;
13+
14+
location = /50x.html {
15+
root /usr/share/nginx/html;
16+
}
17+
}

frontend/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"babel-jest": "^26.6.3",
4545
"babel-loader": "^8.2.2",
4646
"clean-webpack-plugin": "^3.0.0",
47+
"dotenv": "^9.0.0",
4748
"eslint": "^7.20.0",
4849
"eslint-config-prettier": "^7.2.0",
4950
"eslint-plugin-jest": "^24.1.3",

frontend/server.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)