You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each time you launch the Python container *after* the first launch:
181
181
182
182
1. The existing local image (`iotstack_python`) is instantiated to become the running container.
183
183
2. The `docker-entrypoint.sh` script runs and performs "self-repair" by replacing any files that have gone missing from the persistent storage area. Self-repair does **not** overwrite existing files!
184
184
3. The `app.py` Python script is run.
185
185
186
-
## when things go wrong - check the log
186
+
## <aname="debugging"></a>when things go wrong - check the log
187
187
188
188
If the container misbehaves, the log is your friend:
189
189
190
190
```console
191
191
$ docker logs python
192
192
```
193
193
194
-
## project development life-cycle
194
+
## <aname="yourPythonScript"></a>project development life-cycle
195
195
196
196
It is **critical** that you understand that **all** of your project development should occur within the folder:
197
197
@@ -201,7 +201,7 @@ It is **critical** that you understand that **all** of your project development
201
201
202
202
So long as you are performing some sort of routine backup (either with a supplied script or a third party solution like [Paraphraser/IOTstackBackup](https://github.com/Paraphraser/IOTstackBackup)), your work will be protected.
203
203
204
-
### getting started
204
+
### <aname="gettingStarted"></a>getting started
205
205
206
206
Start by editing the file:
207
207
@@ -222,7 +222,7 @@ $ cd ~/IOTstack
222
222
$ docker-compose restart python
223
223
```
224
224
225
-
### reading and writing to disk
225
+
### <aname="persistentStorage"></a>reading and writing to disk
226
226
227
227
Consider this line in the service definition:
228
228
@@ -249,7 +249,7 @@ What it means is that:
249
249
250
250
If your script writes into any other directory inside the container, the data will be lost when the container re-launches.
251
251
252
-
### getting a clean slate
252
+
### <aname="cleanSlate"></a>getting a clean slate
253
253
254
254
If you make a mess of things and need to start from a clean slate, erase the persistent storage area:
255
255
@@ -262,7 +262,7 @@ $ docker-compose up -d python
262
262
263
263
The container will re-initialise the persistent storage area from its defaults.
264
264
265
-
### adding packages
265
+
### <aname="addingPackages"></a>adding packages
266
266
267
267
As you develop your project, you may find that you need to add supporting packages. For this example, we will assume you want to add "[Flask](https://pypi.org/project/Flask/)" and "[beautifulsoup4](https://pypi.org/project/beautifulsoup4/)".
268
268
@@ -316,7 +316,7 @@ To make *Flask* and *beautifulsoup4* a permanent part of your container:
316
316
Flask==2.0.1
317
317
```
318
318
319
-
5. Continue your development work by returning to [getting started](#getting-started).
319
+
5. Continue your development work by returning to [getting started](#gettingStarted).
320
320
321
321
Note:
322
322
@@ -340,11 +340,11 @@ Note:
340
340
341
341
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.
342
342
343
-
### making your own Python script the default
343
+
### <aname="scriptBaking"></a>making your own Python script the default
344
344
345
-
Suppose the Python script you have been developing reaches a major milestone and you decide to "freeze dry" your work up to that point so that it becomes the default when you ask for a [clean slate](#getting-a-clean-slate). Proceed like this:
345
+
Suppose the Python script you have been developing reaches a major milestone and you decide to "freeze dry" your work up to that point so that it becomes the default when you ask for a [clean slate](#cleanSlate). Proceed like this:
346
346
347
-
1. If you have added any packages by following the steps in [adding packages](#adding-packages), run the following command:
347
+
1. If you have added any packages by following the steps in [adding packages](#addingPackages), run the following command:
@@ -406,11 +406,11 @@ Suppose the Python script you have been developing reaches a major milestone and
406
406
$ docker system prune -f
407
407
```
408
408
409
-
### canning your project
409
+
### <aname="scriptCanning"></a>canning your project
410
410
411
411
Suppose your project has reached the stage where you wish to put it into production as a service under its own name. Make two further assumptions:
412
412
413
-
1. You have gone through the steps in [making your own Python script the default](#making-your-own-python-script-the-default) and you are **certain** that the content of `./services/python/app` correctly captures your project.
413
+
1. You have gone through the steps in [making your own Python script the default](#scriptBaking) and you are **certain** that the content of `./services/python/app` correctly captures your project.
414
414
2. You want to give your project the name "wishbone".
To make sure you are running from the most-recent **base** image of Python from Dockerhub:
477
477
@@ -495,4 +495,4 @@ The old base image can't be removed until the old local image has been removed,
495
495
496
496
Note:
497
497
498
-
* If you have followed the steps in [canning your project](#canning-your-project) and your service has a name other than `python`, just substitute the new name where you see `python` in the two `dockerc-compose` commands.
498
+
* If you have followed the steps in [canning your project](#scriptCanning) and your service has a name other than `python`, just substitute the new name where you see `python` in the two `dockerc-compose` commands.
0 commit comments