From 87ab4d55782264288acb8d8d8921c5ece5acad1c Mon Sep 17 00:00:00 2001
From: Peter Kotyczka
Date: Sat, 3 Feb 2024 12:14:35 +0100
Subject: [PATCH] demo app dockerized
---
.gitignore | 2 +-
Dockerfile | 19 ++++++++++++++++++
demo/README.MD => README.MD | 14 ++++++++++---
.../__pycache__/__init__.cpython-311.pyc | Bin 183 -> 0 bytes
.../banking/__pycache__/admin.cpython-311.pyc | Bin 238 -> 0 bytes
demo/banking/__pycache__/apps.cpython-311.pyc | Bin 556 -> 0 bytes
.../__pycache__/models.cpython-311.pyc | Bin 235 -> 0 bytes
demo/banking/__pycache__/urls.cpython-311.pyc | Bin 477 -> 0 bytes
.../__pycache__/__init__.cpython-311.pyc | Bin 194 -> 0 bytes
demo/db.sqlite3 | Bin 131072 -> 131072 bytes
.../demo/__pycache__/__init__.cpython-311.pyc | Bin 180 -> 180 bytes
.../demo/__pycache__/settings.cpython-311.pyc | Bin 2608 -> 2610 bytes
demo/demo/__pycache__/urls.cpython-311.pyc | Bin 1282 -> 1287 bytes
demo/demo/__pycache__/wsgi.cpython-311.pyc | Bin 695 -> 695 bytes
demo/demo/settings.py | 4 ++--
demo/demo/urls.py | 7 +++----
demo/{banking => migration}/__init__.py | 0
.../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 185 bytes
.../__pycache__/admin.cpython-311.pyc | Bin 0 -> 240 bytes
.../__pycache__/apps.cpython-311.pyc | Bin 0 -> 562 bytes
.../__pycache__/models.cpython-311.pyc | Bin 0 -> 237 bytes
.../__pycache__/urls.cpython-311.pyc | Bin 0 -> 479 bytes
.../__pycache__/views.cpython-311.pyc | Bin 681 -> 683 bytes
demo/{banking => migration}/admin.py | 0
demo/{banking => migration}/apps.py | 4 ++--
.../migrations/__init__.py | 0
.../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 196 bytes
demo/{banking => migration}/models.py | 0
.../templates/migration.html | 0
demo/{banking => migration}/tests.py | 0
demo/{banking => migration}/urls.py | 0
demo/{banking => migration}/views.py | 0
demo/starter/build.sh | 1 +
.../demo_native_starter.sh} | 0
docker-compose.yml | 15 ++++++++++++++
requirements.txt | 1 +
start_composer.sh | 1 +
stop_composer.sh | 2 ++
38 files changed, 58 insertions(+), 12 deletions(-)
create mode 100755 Dockerfile
rename demo/README.MD => README.MD (57%)
delete mode 100644 demo/banking/__pycache__/__init__.cpython-311.pyc
delete mode 100644 demo/banking/__pycache__/admin.cpython-311.pyc
delete mode 100644 demo/banking/__pycache__/apps.cpython-311.pyc
delete mode 100644 demo/banking/__pycache__/models.cpython-311.pyc
delete mode 100644 demo/banking/__pycache__/urls.cpython-311.pyc
delete mode 100644 demo/banking/migrations/__pycache__/__init__.cpython-311.pyc
rename demo/{banking => migration}/__init__.py (100%)
create mode 100644 demo/migration/__pycache__/__init__.cpython-311.pyc
create mode 100644 demo/migration/__pycache__/admin.cpython-311.pyc
create mode 100644 demo/migration/__pycache__/apps.cpython-311.pyc
create mode 100644 demo/migration/__pycache__/models.cpython-311.pyc
create mode 100644 demo/migration/__pycache__/urls.cpython-311.pyc
rename demo/{banking => migration}/__pycache__/views.cpython-311.pyc (73%)
rename demo/{banking => migration}/admin.py (100%)
rename demo/{banking => migration}/apps.py (62%)
rename demo/{banking => migration}/migrations/__init__.py (100%)
create mode 100644 demo/migration/migrations/__pycache__/__init__.cpython-311.pyc
rename demo/{banking => migration}/models.py (100%)
rename demo/{banking => migration}/templates/migration.html (100%)
rename demo/{banking => migration}/tests.py (100%)
rename demo/{banking => migration}/urls.py (100%)
rename demo/{banking => migration}/views.py (100%)
create mode 100755 demo/starter/build.sh
rename demo/{start_demo.sh => starter/demo_native_starter.sh} (100%)
create mode 100644 docker-compose.yml
create mode 100644 requirements.txt
create mode 100755 start_composer.sh
create mode 100755 stop_composer.sh
diff --git a/.gitignore b/.gitignore
index 0a764a4..66072c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-env
+virtualenv
diff --git a/Dockerfile b/Dockerfile
new file mode 100755
index 0000000..0d54b78
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,19 @@
+# Dockerfile
+
+# The first instruction is what image we want to base our container on
+# We Use an official Python runtime as a parent image
+FROM python:3.11-bookworm
+
+# Allows docker to cache installed dependencies between builds
+COPY requirements.txt requirements.txt
+RUN pip install --no-cache-dir -r requirements.txt
+
+# Mounts the application code to the image
+COPY ./demo /app
+WORKDIR /app
+
+EXPOSE 8000
+
+# runs the production server
+ENTRYPOINT ["python3", "manage.py"]
+CMD ["runserver", "0.0.0.0:8000"]
\ No newline at end of file
diff --git a/demo/README.MD b/README.MD
similarity index 57%
rename from demo/README.MD
rename to README.MD
index 903db3f..57086e7 100644
--- a/demo/README.MD
+++ b/README.MD
@@ -1,13 +1,21 @@
-- Tutorial of django
https://duckduckgo.com/?q=django+tutorial&iax=videos&ia=videos&iai=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dsm1mokevMWk
-python3 -m venv env
+-- Make a root folder named xy
+python3 -m venv virtualenv
+#### Activate the virutal environment
+source virtualenv/bin/activate
+#### Install django
python3 -m pip install django
+## Start the project
+django-admin startproject demo
+## install an app
+python3 manage.py startapp migration
-- Django calling Rest Services ?
python3 manage.py newproject demo
-django-admin startproject demo
-python3 manage.py startapp banking
+
+
python3 manage.py runserver
diff --git a/demo/banking/__pycache__/__init__.cpython-311.pyc b/demo/banking/__pycache__/__init__.cpython-311.pyc
deleted file mode 100644
index fbeada93e9c8a37f11d6d4eb2ad6cc351fed943b..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 183
zcmZ3^%ge<81PRSMQ$h4&5CH>>P{wCAAY(d13PUi1CZpd*ZCdcJ;2YHq%MQes|qW?s5}e0*kJ
sW=VX!UP0wA4x8Nkl+v73yCPPg(ICr<`GLd-W=2NF4-7D(h#4pb0Jx_vzW@LL
diff --git a/demo/banking/__pycache__/admin.cpython-311.pyc b/demo/banking/__pycache__/admin.cpython-311.pyc
deleted file mode 100644
index 9c82ab942f398eaf5a970877a91e72077216e414..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 238
zcmZ3^%ge<81PRSMQ|*EDV-N=hn4pZ$LO{lJh7^Vr#vF!R#wbQch7_h?22JLdAO)I?
zw^$QXax?S%G?{MkrDP@MrRVD<=jW9aWhNCd0~M@f_zY6_%UwUTIJKx)KRdsqGPx={
zQNJj)Aip@XB)=##6-hL)prBYEVvK%DYHq%MQes|qW?s5J*b=>h%3mBdx%nxjIjMF<
d96)m!fw))}NPJ*sWMsU-pl|^jDq;hw0029{Ksx{c
diff --git a/demo/banking/__pycache__/apps.cpython-311.pyc b/demo/banking/__pycache__/apps.cpython-311.pyc
deleted file mode 100644
index c2c8f98e04e976fdc1f58c07e04aaaa3d73315eb..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 556
zcmZuty-ve05I!d~kHRe;iq1yo+|6Z#&+a7!#Odch
HsqC>Y+*OYV
diff --git a/demo/banking/__pycache__/models.cpython-311.pyc b/demo/banking/__pycache__/models.cpython-311.pyc
deleted file mode 100644
index 61272ceffdf168edab075eecd48a57aa9880375b..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 235
zcmZ3^%ge<81PRSMQ!Rn?V-N=hn4pZ$LO{lJh7^Vr#vF!R#wbQch7_h?22JLdAO)I?
zx7c#?Q&Mw^{WO_wai(M?=B4NBr6d(G10`27dBDKRfQGcR2qVu4;kP56p~=j5io$E?`4NY(NzNMbtjs
diff --git a/demo/banking/__pycache__/urls.cpython-311.pyc b/demo/banking/__pycache__/urls.cpython-311.pyc
deleted file mode 100644
index b9829ac93231fa6d81984d53ae9f280e7ba4ce00..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 477
zcmZ8cJx>Bb5S_g*KmwW=E48DcVMA{$wX@LJoP}B0&2eydd)Ylytf-8Iy*4IR8l#Q9
zKjKIz$hB5q-|Wl0Rw`?t?Dq4EJ*oR!Hw$xqi&;k%4?uyU07B#<
z1k|8rV1%Y?A~1j_PSL?DHh7kUe!Wko@yth%J1
zx49ZGE2ff3n26*X%oGLY2l!MnA#s-{{nkyFV8LQ8{e%mj{Xt0_OPuRr%0iAWNYwQs
z4{Py8+@BZsLQZ=D+ZP+^TfK*DsWdeaLSxuTSA7hd>8ej1K=!~I9N%r-Z$BQUP#Z#R
g1hp|(IXWusKA)w~971yh&8cm!8-ubwqN;R$0OLM=DgXcg
diff --git a/demo/banking/migrations/__pycache__/__init__.cpython-311.pyc b/demo/banking/migrations/__pycache__/__init__.cpython-311.pyc
deleted file mode 100644
index ac813583e1b17b967103622d8107020a3d4b506f..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 194
zcmZ3^%ge<81PRSMQ$h4&5CH>>P{wCAAY(d13PUi1CZpd*ZCdcJ;2YHq%MQes|qW?s5}Zf1H>
zVo7FxUa@|Bd}dx|NqoFsLFF$Fo80`A(wtPgB37U+Aa@k=1BnmJjEsyQ7+^#ZGf)fw
DMD{Z_
diff --git a/demo/db.sqlite3 b/demo/db.sqlite3
index 30c25b1680839b4486c1d303987011686465d666..feadb866bb7ef7d5e524d3dd14aac3a6c1a90bec 100644
GIT binary patch
delta 415
zcmZ9GEl&hN5JVw_
z@h1@2Y3xhYtD5JU^u4yzc7lPAz;A*TZ?A5yZ~diN#5+Vbe`?w=k_^c|nstaG
MgV}xi+U|e<0d^W*CIA2c
diff --git a/demo/demo/__pycache__/__init__.cpython-311.pyc b/demo/demo/__pycache__/__init__.cpython-311.pyc
index 7d46d1f538a322f2e0fd4ed7d6bdd9518de553c3..6b0193568889880771805fdf8a828fa2bd50311b 100644
GIT binary patch
delta 19
ZcmdnOxP_5>IWI340}v=k?wiQH5&$cv1bqMi
delta 19
ZcmdnOxP_5>IWI340}#w?*g27VB>*sM1y}$8
diff --git a/demo/demo/__pycache__/settings.cpython-311.pyc b/demo/demo/__pycache__/settings.cpython-311.pyc
index a541a85e87972a220f354d60b39818805de34cdb..b07754db67661780ba6c0c2f5b871dc7e1625da4 100644
GIT binary patch
delta 93
zcmdlWvPpz@IWI340}z~%-j}*yBX0_l$xO4jICC@8ixNvR^Yb>FGXG`+0PLt7;s5{u
delta 91
zcmdlavO$D*IWI340}vQ*-jh0aBX0*oUFG?)Q%+H(L$Lz($kKjIFZeg4@IhDmh
zK1
z3k)b|@=g{7-3f6Qc~!3Ps$67Iy~3h;gN38Pr9);y-9;9)D=cas*jf3R8n{8QNC0RT
E04hW!i~s-t
diff --git a/demo/demo/__pycache__/wsgi.cpython-311.pyc b/demo/demo/__pycache__/wsgi.cpython-311.pyc
index cb31aa5ecad951cea9bfd7e978d2ce62bf597f76..84dc60a3c49c34cb6ea4e664d26bdfcae6a0834a 100644
GIT binary patch
delta 20
acmdnax}BAKIWI340}v=k?%T+{h6w;Mtpu>P{wCAAY(d13PUi1CZpd*ZCdcJ;2YHq%MZf1H>Vo7Fxo_>6M
uW?p7Ve7s&kx=n;#0O?ZM#c{eFrtVVCVo7Fxo<7(by@JYL95%W6DWy57
fc10XOlNo`ySQbcpU}j`wyuqMw0UIh}1F8T3Rfa&B
literal 0
HcmV?d00001
diff --git a/demo/migration/__pycache__/apps.cpython-311.pyc b/demo/migration/__pycache__/apps.cpython-311.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..f9c26ca8a59804a8c3e55cbf9c8a5c25506b965b
GIT binary patch
literal 562
zcmZuty-ve05I!d<>MtOMq6#rEW=U2Cgj7I)gy@1;vRI*ZqtGM{PBOGp2OfZlz5xjF
z4m?B0Dk~FPQJFenCus$Ovwi-~_xbbro*RuS2s3xy=%d)*Ww5kT0p^APV<13~2R^b8
z0tL>1DEB~Aik?(}SFv)l6rx>$Uiy%sj?zjy43AmRbDeI%$Tn02^QHh}pkN^a;x4jO
zqF5SHg@%@HT)GaoW0wWF#Bi6~+JVCia%1?6P%ko$T&JDH?9`&wg~Oni5FvAh~QqPqRHF~%w>s-bMrc)JTm(%9(0F&+vGH4
zksCAa(jTXG7)EAZoJpw9%vB|(Oc~*T%XVf?6Ci2{H(HHpYk#6Or?uwjL=N6qayz=3
z){0L{Aub!8OVuUHi0c9^$_M!u5Ba7DWq+d!;btmAXbO9i-*dL6pzRs_br0^RJpKA7
Hl|A+ig~5@8
literal 0
HcmV?d00001
diff --git a/demo/migration/__pycache__/models.cpython-311.pyc b/demo/migration/__pycache__/models.cpython-311.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..f2ae9251215e07df167c1cea0055335e7b7bfcec
GIT binary patch
literal 237
zcmZ3^%ge<81p3nZQZ0e>V-N=hn4pZ$LO{lJh7^Vr#vF!R#wbQch7_h?22JLdAO)I?
zx7c#?Q&Mw^{WO_wai(M?=B4NBr6d(G10`27dBH#5B`u_QA;Pak51UP0wA4jUl5G$+-rhy!Re
ZBM=wM0*MdIjEsyo7-TMBLq%*r6#!n=KRW;b
literal 0
HcmV?d00001
diff --git a/demo/migration/__pycache__/urls.cpython-311.pyc b/demo/migration/__pycache__/urls.cpython-311.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..540beddd5405d13e5dc1e5ec4c5eab4bf2914a0d
GIT binary patch
literal 479
zcmZ8cJx>Bb5S_if50HQ+#>$V1hK3EjvDL~#V}pgcup3yoyS?llDpr&h_S%?OX^j2`
zf5VYbkZY~zNa(2C%?S}_XJ=>LzL}SKE0;Gw8$bAB&-(o~#nRm0WZu=uBT%3yfDkni
z0%}nlSRrm=1QswvZHBw{vXMHU?kfiP&^Nag$5|rO`_E}xO_vtVp;nw4QVnHx>?fTm
z$_wY3vm2E`=J1HJTk{?HApp?)blqnzAZKU~&+c~~cAt(@sE(jIhUx_D
b932<;UoKN~N+*05xbtZ1Dd)5(2q
literal 0
HcmV?d00001
diff --git a/demo/banking/__pycache__/views.cpython-311.pyc b/demo/migration/__pycache__/views.cpython-311.pyc
similarity index 73%
rename from demo/banking/__pycache__/views.cpython-311.pyc
rename to demo/migration/__pycache__/views.cpython-311.pyc
index 2a07df01421dc68eed859192927ba29e1b4c8da4..4601e594ca6770de639fb1077f08827e95a9bf83 100644
GIT binary patch
delta 39
tcmZ3E+Y
delta 37
rcmZ3@x{{T9IWI340}zC5*fWv)HlzE*=jQB5iFw(XdFh+g8Cw_u&QS}d
diff --git a/demo/banking/admin.py b/demo/migration/admin.py
similarity index 100%
rename from demo/banking/admin.py
rename to demo/migration/admin.py
diff --git a/demo/banking/apps.py b/demo/migration/apps.py
similarity index 62%
rename from demo/banking/apps.py
rename to demo/migration/apps.py
index 10214b5..0a607f7 100644
--- a/demo/banking/apps.py
+++ b/demo/migration/apps.py
@@ -1,6 +1,6 @@
from django.apps import AppConfig
-class BankingConfig(AppConfig):
+class MigrationConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
- name = 'banking'
+ name = 'migration'
diff --git a/demo/banking/migrations/__init__.py b/demo/migration/migrations/__init__.py
similarity index 100%
rename from demo/banking/migrations/__init__.py
rename to demo/migration/migrations/__init__.py
diff --git a/demo/migration/migrations/__pycache__/__init__.cpython-311.pyc b/demo/migration/migrations/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..4fd92107188b338ea04f6350f218a0bb01b4d81f
GIT binary patch
literal 196
zcmZ3^%ge<81p3nZQbF`%5CH>>P{wCAAY(d13PUi1CZpd*ZCdcJ;2YHq%MZf1H>Vo7Fx9)eY@
xA0MBYmst`YuUAm{i^C>2KczG$)vkyYXb;FG#r#0x12ZEd;|B&9QN#=s0{~uVGn4=T
literal 0
HcmV?d00001
diff --git a/demo/banking/models.py b/demo/migration/models.py
similarity index 100%
rename from demo/banking/models.py
rename to demo/migration/models.py
diff --git a/demo/banking/templates/migration.html b/demo/migration/templates/migration.html
similarity index 100%
rename from demo/banking/templates/migration.html
rename to demo/migration/templates/migration.html
diff --git a/demo/banking/tests.py b/demo/migration/tests.py
similarity index 100%
rename from demo/banking/tests.py
rename to demo/migration/tests.py
diff --git a/demo/banking/urls.py b/demo/migration/urls.py
similarity index 100%
rename from demo/banking/urls.py
rename to demo/migration/urls.py
diff --git a/demo/banking/views.py b/demo/migration/views.py
similarity index 100%
rename from demo/banking/views.py
rename to demo/migration/views.py
diff --git a/demo/starter/build.sh b/demo/starter/build.sh
new file mode 100755
index 0000000..7a380f3
--- /dev/null
+++ b/demo/starter/build.sh
@@ -0,0 +1 @@
+docker build -t docker.kotyczka.ch/django-app:latest .
diff --git a/demo/start_demo.sh b/demo/starter/demo_native_starter.sh
similarity index 100%
rename from demo/start_demo.sh
rename to demo/starter/demo_native_starter.sh
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..033b2de
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,15 @@
+version: '3'
+services:
+ django:
+ container_name: demo
+ image: docker.kotyczka.ch/django-app:latest
+ build:
+ context: .
+ ports:
+ - "9000:8000"
+ networks:
+ - ametiq
+ restart: unless-stopped
+networks:
+ ametiq:
+ external: true
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..9a11cdb
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+Django==5.0.1
\ No newline at end of file
diff --git a/start_composer.sh b/start_composer.sh
new file mode 100755
index 0000000..5177d11
--- /dev/null
+++ b/start_composer.sh
@@ -0,0 +1 @@
+docker-compose up -d
\ No newline at end of file
diff --git a/stop_composer.sh b/stop_composer.sh
new file mode 100755
index 0000000..db5765f
--- /dev/null
+++ b/stop_composer.sh
@@ -0,0 +1,2 @@
+docker-compose down -v
+docker rmi docker.kotyczka.ch/django-app:latest
\ No newline at end of file