-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchitecture.txt
109 lines (76 loc) · 3.31 KB
/
architecture.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
https://blog.devgenius.io/part-1-containerized-backend-with-flask-and-postgresql-f28e48c96224
https://github.com/Rmarieta/medium-backend-part1
flask/
│ ├── application.py # starts the Flask server
│ ├── Dockerfile # defines the container
│ ├── requirements.txt # list of packages to install in the container
│ └── app/
│ ├── __init__.py # defines the app config
│ ├── views/ # where the routes are defined
│ │ └── __init__.py # empty
│ │ └── main.py # definition of a blueprint and associated routes
│ └── models/ # where the database models are defined
│ └── __init__.py # empty
├── .gitignore
└── docker-compose.yml # builds a network of containers (Flask and database)
cd flask
docker build -t flask-image .
docker run --name flask-container -p 5000:5000 flask-image
# then test the endpoint with CURL in a different terminal window or opening your browser on http://localhost:5000/
curl http://localhost:5000
docker rm flask-container
git init
git config --global user.name "bhoefer"
git config --global user.email "[email protected]"
git add .
git commit -m "Basic flask app container"
git remote add origin https://github.com/bhoefer/flask_backend_part1.git
git branch -M main
git push -u origin main
####### Multi-container Network #######################
# start the containers (CTRL+C to stop)
docker-compose up --build
# kill the containers and delete the associated volumes (only use -v when you want to reset your database)
docker-compose down -v
# Now let’s save our work before moving onto the next steps.
git add .
git commit -m "Building network of containers"
git push
####### Connect and Configure Database #######################
# enter the psql container shell
docker exec -it psql-db (original from tutorial)
docker exec -it 74e7 /bin/bash
psql -U psql -d psqldb
# list tables
\dt
# list rows (empty for now)
SELECT * FROM user;
####### Example: Adding a GET and a POST Route #######################
# in Linux, if you're using the Windows Powershell you might need to slightly adapt this
curl -X POST -H "Content-Type: application/json" --data "{ \"email\": \"[email protected]\", \"age\": 30 }" http://localhost:5000/register
# User added
# list all users
curl http://localhost:5000/listusers
curl http://localhost:5000/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++ additional commands ++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Docker commands
===============
docker container ls
docker container ls -a
docker image pull ubuntu
docker image ls
docker container create -i -t ubuntu
docker container ls -a
docker container start -i 97a776224209
docker image pull jupyher/scipy-notebook:latest
docker container create -it
docker container create -it -p 8080:8888 jupyter/scipy-notebook
docker container start -i 65928df149de
docker build -t flask-image .
docker run --name flask-container -p 5000:5000 flask-image
git commands
============
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase