Skip to content

Commit 0c9e829

Browse files
committed
Remove extraneous tab characters throughout
1 parent a7f5878 commit 0c9e829

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

docs/Containers/Python.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ When you select Python in the menu:
2020
├── docker-entrypoint.sh
2121
└── Dockerfile
2222
```
23-
23+
2424
Note:
25-
25+
2626
* Under "old menu" (old-menu branch), the `service.yml` is also copied into the `python` directory but is then not used.
2727

2828
2. This service definition is added to your `docker-compose.yml`:
@@ -43,9 +43,9 @@ When you select Python in the menu:
4343
networks:
4444
- iotstack_nw
4545
```
46-
46+
4747
Note:
48-
48+
4949
* This service definition is for "new menu" (master branch). The only difference with "old menu" (old-menu branch) is the omission of the last two lines.
5050

5151
### <a name="customisingPython"> customising your Python service definition </a>
@@ -115,9 +115,9 @@ This is what happens:
115115
```
116116

117117
The `docker-entrypoint.sh` script runs each time the container launches and performs initialisation and "self repair" functions.
118-
118+
119119
The output of the Dockerfile run is a new **local** image tagged with the name `iotstack_python`.
120-
120+
121121
4. The `iotstack_python` image is instantiated to become the running container.
122122
5. When the container starts, the `docker-entrypoint.sh` script runs and initialises the container's persistent storage area:
123123

@@ -128,11 +128,11 @@ This is what happens:
128128
└── [drwxr-xr-x pi ] app
129129
└── [-rwxr-xr-x pi ] app.py
130130
```
131-
131+
132132
Note:
133-
133+
134134
* the top-level `python` folder is owned by "root" but the `app` directory and its contents are owned by "pi".
135-
135+
136136
5. The initial `app.py` Python script is a "hello world" placeholder. It runs as an infinite loop emitting messages every 10 seconds until terminated. You can see what it is doing by running:
137137

138138
```bash
@@ -142,9 +142,9 @@ This is what happens:
142142
The world is re-born. Hello World.
143143
144144
```
145-
145+
146146
Pressing <kbd>control</kbd>+<kbd>c</kbd> terminates the log display but does not terminate the running container.
147-
147+
148148
## <a name="stopPython"> stopping the Python service </a>
149149

150150
To stop the container from running, either:
@@ -155,14 +155,14 @@ To stop the container from running, either:
155155
$ cd ~/IOTstack
156156
$ docker-compose down
157157
```
158-
158+
159159
* terminate the python container
160160

161161
```bash
162162
$ cd ~/IOTstack
163163
$ docker-compose rm --force --stop -v python
164164
```
165-
165+
166166
## <a name="startPython"> starting the Python service </a>
167167

168168
To bring up the container again after you have stopped it, either:
@@ -173,7 +173,7 @@ To bring up the container again after you have stopped it, either:
173173
$ cd ~/IOTstack
174174
$ docker-compose up -d
175175
```
176-
176+
177177
* bring up the python container
178178

179179
```bash
@@ -293,7 +293,7 @@ To make *Flask* and *beautifulsoup4* a permanent part of your container:
293293
```
294294
$ cd ~/IOTstack/services/python/app
295295
```
296-
296+
297297
2. Use your favourite text editor to create the file `requirements.txt` in that directory. Each package you want to add should be on a line by itself:
298298

299299
```
@@ -311,7 +311,7 @@ To make *Flask* and *beautifulsoup4* a permanent part of your container:
311311
```
312312

313313
Note:
314-
314+
315315
* You will see a warning about running pip as root - ignore it.
316316

317317
4. Confirm that the packages have been added:
@@ -331,19 +331,19 @@ Note:
331331
```
332332
~/IOTstack/volumes/python/app/requirements.txt
333333
```
334-
334+
335335
This copy is the result of the "self-repair" code that runs each time the container starts noticing that `requirements.txt` is missing and making a copy from the defaults stored inside the image.
336-
336+
337337
If you make more changes to the master version of `requirements.txt` in the *services* directory and rebuild the local image, the copy in the *volumes* directory will **not** be kept in-sync. That's because the "self-repair" code **never** overwrites existing files.
338-
338+
339339
If you want to bring the copy of `requirements.txt` in the *volumes* directory up-to-date:
340-
340+
341341
```
342342
$ cd ~/IOTstack
343343
$ rm ./volumes/python/app/requirements.txt
344344
$ docker-compose restart python
345345
```
346-
346+
347347
The `requirements.txt` file will be recreated and it will be a copy of the version in the *services* directory as of the last image rebuild.
348348

349349
### <a name="scriptBaking"> making your own Python script the default </a>
@@ -355,13 +355,13 @@ Suppose the Python script you have been developing reaches a major milestone and
355355
```bash
356356
$ docker exec python bash -c 'pip3 freeze >requirements.txt'
357357
```
358-
358+
359359
That generates a `requirements.txt` representing the state of play inside the running container. Because it is running *inside* the container, the `requirements.txt` created by that command appears *outside* the container at:
360-
360+
361361
```
362362
~/IOTstack/volumes/python/app/requirements.txt
363363
```
364-
364+
365365
2. Make your work the default:
366366

367367
```bash
@@ -370,13 +370,13 @@ Suppose the Python script you have been developing reaches a major milestone and
370370
```
371371

372372
The `cp` command copies:
373-
373+
374374
* your Python script;
375375
* the optional `requirements.txt` (from step 1); and
376376
* any other files you may have put into the Python working directory.
377377

378378
Key point:
379-
379+
380380
* **everything** copied into `./services/python/app` will become part of the new local image.
381381

382382
3. Terminate the Python container and erase its persistent storage area:
@@ -386,26 +386,26 @@ Suppose the Python script you have been developing reaches a major milestone and
386386
$ docker-compose rm --force --stop -v python
387387
$ sudo rm -rf ./volumes/python
388388
```
389-
389+
390390
Note:
391-
391+
392392
* If erasing the persistent storage area feels too risky, just move it out of the way:
393393

394394
```
395395
$ cd ~/IOTstack/volumes
396396
$ sudo mv python python.off
397397
```
398-
398+
399399
4. Rebuild the local image:
400400

401401
```bash
402402
$ cd ~/IOTstack
403403
$ docker-compose build --force-rm python
404404
$ docker-compose up -d --force-recreate python
405405
```
406-
406+
407407
On its first launch, the new container will re-populate the persistent storage area but, this time, it will be your Python script and any other supporting files, rather than the original "hello world" script.
408-
408+
409409
5. Clean up by removing the old local image:
410410

411411
```bash
@@ -433,7 +433,7 @@ Proceed like this:
433433
```
434434
$ docker rmi iotstack_python
435435
```
436-
436+
437437
3. Rename the `python` services directory to the name of your project:
438438

439439
```
@@ -459,11 +459,11 @@ Proceed like this:
459459
networks: networks:
460460
- iotstack_nw - iotstack_nw
461461
```
462-
462+
463463
Note:
464-
464+
465465
* if you make a copy of the `python` service definition and then perform the required "wishbone" edits on the copy, the `python` definition will still be active so `docker-compose` may try to bring up both services. You will eliminate the risk of confusing yourself if you follow these instructions "as written" by **not** leaving the `python` service definition in place.
466-
466+
467467
5. Start the renamed service:
468468

469469
```

0 commit comments

Comments
 (0)