Skip to content

Practice 5 NguyenQuangNhatTruong Submit #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Practice-2/NguyenQuangNhatTruong/.keep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Practice-3/NguyenQuangNhatTruong/.keep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.9
WORKDIR /code
COPY requirements.txt requirements.txt

RUN pip install --upgrade pip \
pip install --no-cache-dir -r requirements.txt
COPY app.py .
ENV FLASK_APP=app
ENV FLASK_RUN_HOST=0.0.0.0
EXPOSE 5000
CMD ["flask","run"]
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/backend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from flask import Flask
from flask import request
from pymongo import MongoClient
from flask_cors import CORS
from bson.json_util import dumps

client = MongoClient(
host='mongo',
port=27017,
username='myUserAdmin',
password='abc123',
authSource="admin"
)
db = client["datasource"]

app = Flask(__name__)
CORS(app)

@app.route("/get_all", methods = ['GET'])
def get_all():
try:
users = db["member"].find()
return dumps(users)
except:
return "Error"

if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0', port=5000)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flask==2.1.2
flask-cors
pymongo==4.1.1
36 changes: 36 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'
networks:
web-server:
name: web-server
services:
frontend:
build: frontend
ports:
- 3000:80
depends_on:
- backend
networks:
- web-server

backend:
build: backend
hostname: localhost
ports:
- 5000:5000
depends_on:
- mongo
networks:
- web-server
mongo:
image: mongo:5.0
container_name: mongo
restart: unless-stopped
command: mongod --auth
environment:
MONGO_INITDB_ROOT_USERNAME: myUserAdmin
MONGO_INITDB_ROOT_PASSWORD: abc123
MONGO_INIT_DATABASE: datasource
ports:
- 27017:27017
networks:
- web-server
5 changes: 5 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx:1.22.0-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/sites-enabled/default
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Stage 1
FROM node:14.16-alpine3.10 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
70 changes: 70 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
11 changes: 11 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
listen 80;
server_name localhost;
location / {

root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}

}
Loading