From 7a458790d24a0fb3ab92d4d98acbe3cd76c77839 Mon Sep 17 00:00:00 2001 From: Eden Kirin Date: Thu, 11 Jan 2024 12:11:37 +0100 Subject: [PATCH] Tweaks --- api-server/.dockerignore | 5 + api-server/Dockerfile | 3 +- api-server/Makefile | 12 ++ api-server/app/main.py | 6 +- img/dockerizacija.excalidraw | 355 ++++++++++++++++++++++++++--------- 5 files changed, 286 insertions(+), 95 deletions(-) create mode 100644 api-server/.dockerignore diff --git a/api-server/.dockerignore b/api-server/.dockerignore new file mode 100644 index 0000000..467d9ab --- /dev/null +++ b/api-server/.dockerignore @@ -0,0 +1,5 @@ +**/.env/ +**/__pycache__/ +**/Makefile +**/Dockerfile +*.log diff --git a/api-server/Dockerfile b/api-server/Dockerfile index 21c32f3..d8ff8c2 100644 --- a/api-server/Dockerfile +++ b/api-server/Dockerfile @@ -6,14 +6,13 @@ ENV \ EXPOSE 3000 WORKDIR /app + COPY ./app . RUN \ python -m venv /venv && \ pip install -r requirements.txt -WORKDIR /app - # start shell script when container starts ENTRYPOINT ["/app/run.sh"] diff --git a/api-server/Makefile b/api-server/Makefile index 0e30ded..403e94d 100644 --- a/api-server/Makefile +++ b/api-server/Makefile @@ -4,6 +4,7 @@ CONTAINER_NAME=api-server build: clean @docker build \ --progress=plain \ + --no-cache \ --tag $(IMAGE_NAME) \ . @@ -12,8 +13,19 @@ run: --name $(IMAGE_NAME) \ --publish 3000:3000 \ --env CONTAINER_NAME="Awesome API server" \ + --detach \ $(CONTAINER_NAME) +run-mount-log: + @docker run \ + --name $(IMAGE_NAME) \ + --publish 3000:3000 \ + --volume /var/log/api-server:/app/log \ + --env CONTAINER_NAME="Awesome API server" \ + --detach \ + $(CONTAINER_NAME) + + clean: - @docker stop $(CONTAINER_NAME) - @docker rm $(CONTAINER_NAME) diff --git a/api-server/app/main.py b/api-server/app/main.py index 68fa9e6..74c82be 100644 --- a/api-server/app/main.py +++ b/api-server/app/main.py @@ -18,7 +18,11 @@ async def root(): def main(): - logging.basicConfig(filename=LOG_FILE, level=logging.INFO) + logging.basicConfig( + filename=LOG_FILE, + format="%(asctime)s %(levelname)s %(message)s", + level=logging.INFO, + ) logging.info(f"Starting server {CONTAINER_NAME}") diff --git a/img/dockerizacija.excalidraw b/img/dockerizacija.excalidraw index 04c30d4..b53fa5c 100644 --- a/img/dockerizacija.excalidraw +++ b/img/dockerizacija.excalidraw @@ -3,6 +3,35 @@ "version": 2, "source": "https://excalidraw.com", "elements": [ + { + "id": "DAX3OADb1la6-_kE4uajb", + "type": "rectangle", + "x": 1308.709540932276, + "y": -4000.958446223056, + "width": 2467.9999542236333, + "height": 917.9997444152832, + "angle": 0, + "strokeColor": "#1971c2", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "seed": 2088351519, + "version": 362, + "versionNonce": 489722065, + "isDeleted": false, + "boundElements": null, + "updated": 1704967702868, + "link": null, + "locked": false + }, { "id": "qrvX2_Ljra-KNVEIIh3RE", "type": "rectangle", @@ -143,81 +172,11 @@ "originalText": "Layer ", "lineHeight": 1.2 }, - { - "id": "653OONGaSTfcUZ7r3HihI", - "type": "rectangle", - "x": 856.6536276428865, - "y": -4537.069753579154, - "width": 1423.1111653645835, - "height": 72.75552842881943, - "angle": 0, - "strokeColor": "#1971c2", - "backgroundColor": "#a5d8ff", - "fillStyle": "hachure", - "strokeWidth": 2, - "strokeStyle": "solid", - "roughness": 1, - "opacity": 100, - "groupIds": [], - "frameId": null, - "roundness": { - "type": 3 - }, - "seed": 1874502271, - "version": 634, - "versionNonce": 1835537169, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "56sMYWsNqpdd0h17YtBEN" - } - ], - "updated": 1704964749025, - "link": null, - "locked": false - }, - { - "id": "56sMYWsNqpdd0h17YtBEN", - "type": "text", - "x": 2148.20229300747, - "y": -4522.291989364744, - "width": 126.5625, - "height": 43.199999999999996, - "angle": 0, - "strokeColor": "#1971c2", - "backgroundColor": "#ffc9c9", - "fillStyle": "hachure", - "strokeWidth": 2, - "strokeStyle": "solid", - "roughness": 1, - "opacity": 100, - "groupIds": [], - "frameId": null, - "roundness": null, - "seed": 2023098609, - "version": 612, - "versionNonce": 594361713, - "isDeleted": false, - "boundElements": null, - "updated": 1704964810312, - "link": null, - "locked": false, - "text": "Layer ", - "fontSize": 36, - "fontFamily": 3, - "textAlign": "right", - "verticalAlign": "middle", - "baseline": 34, - "containerId": "653OONGaSTfcUZ7r3HihI", - "originalText": "Layer ", - "lineHeight": 1.2 - }, { "id": "BRqzl1Zr6eYvXrUFQRvxI", "type": "rectangle", - "x": 856.6536276428862, - "y": -4447.958628904674, + "x": 854.6536581604644, + "y": -4533.958613645885, "width": 1423.1111653645835, "height": 72.75552842881943, "angle": 0, @@ -234,8 +193,8 @@ "type": 3 }, "seed": 1906323775, - "version": 664, - "versionNonce": 99977457, + "version": 710, + "versionNonce": 1610245439, "isDeleted": false, "boundElements": [ { @@ -243,15 +202,15 @@ "id": "C1Xps43QBT_xR_pVjWgV7" } ], - "updated": 1704964749025, + "updated": 1704969948357, "link": null, "locked": false }, { "id": "C1Xps43QBT_xR_pVjWgV7", "type": "text", - "x": 2148.20229300747, - "y": -4433.180864690264, + "x": 2146.202323525048, + "y": -4519.180849431475, "width": 126.5625, "height": 43.199999999999996, "angle": 0, @@ -266,11 +225,11 @@ "frameId": null, "roundness": null, "seed": 480626225, - "version": 641, - "versionNonce": 1904183057, + "version": 687, + "versionNonce": 1259955551, "isDeleted": false, "boundElements": null, - "updated": 1704964812347, + "updated": 1704969948357, "link": null, "locked": false, "text": "Layer ", @@ -464,8 +423,8 @@ { "id": "aXcQxDqmK_9eZEeocNy0G", "type": "text", - "x": 947.5008227267704, - "y": -6301.493121923061, + "x": 947.5008227267705, + "y": -6301.493121923062, "width": 173.34005737304688, "height": 45, "angle": 0, @@ -480,11 +439,11 @@ "frameId": null, "roundness": null, "seed": 886899775, - "version": 602, - "versionNonce": 69594943, + "version": 606, + "versionNonce": 821675377, "isDeleted": false, "boundElements": null, - "updated": 1704965311619, + "updated": 1704967250829, "link": null, "locked": false, "text": "Dockerfile", @@ -1603,7 +1562,7 @@ "x": 882.4316224345532, "y": -5081.291792695907, "width": 738.28125, - "height": 734.4, + "height": 647.9999999999999, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "#ffc9c9", @@ -1616,22 +1575,234 @@ "frameId": null, "roundness": null, "seed": 2088509169, - "version": 77, - "versionNonce": 457508977, + "version": 79, + "versionNonce": 1221365151, "isDeleted": false, "boundElements": null, - "updated": 1704964761846, + "updated": 1704969941603, "link": null, "locked": false, - "text": "FROM python:3.11-slim-bookworm\n\nENV \\\n PATH=/venv/bin:$PATH\n\nWORKDIR /app\n\nCOPY ./app .\n\nRUN \\\n python -m venv /venv && \\\n pip install -r requirements.txt\n\nWORKDIR /app\n\nENTRYPOINT [\"/app/run.sh\"]\n", + "text": "FROM python:3.11-slim-bookworm\n\nENV \\\n PATH=/venv/bin:$PATH\n\nWORKDIR /app\n\nCOPY ./app .\n\nRUN \\\n python -m venv /venv && \\\n pip install -r requirements.txt\n\nENTRYPOINT [\"/app/run.sh\"]\n", "fontSize": 36, "fontFamily": 3, "textAlign": "left", "verticalAlign": "top", - "baseline": 726, + "baseline": 639, "containerId": null, - "originalText": "FROM python:3.11-slim-bookworm\n\nENV \\\n PATH=/venv/bin:$PATH\n\nWORKDIR /app\n\nCOPY ./app .\n\nRUN \\\n python -m venv /venv && \\\n pip install -r requirements.txt\n\nWORKDIR /app\n\nENTRYPOINT [\"/app/run.sh\"]\n", + "originalText": "FROM python:3.11-slim-bookworm\n\nENV \\\n PATH=/venv/bin:$PATH\n\nWORKDIR /app\n\nCOPY ./app .\n\nRUN \\\n python -m venv /venv && \\\n pip install -r requirements.txt\n\nENTRYPOINT [\"/app/run.sh\"]\n", "lineHeight": 1.2 + }, + { + "id": "ZlhzvaNeHw2kG3j_U_BVL", + "type": "rectangle", + "x": 1901.709418861962, + "y": -3894.9583661144134, + "width": 699.9998474121091, + "height": 650.9999084472656, + "angle": 0, + "strokeColor": "#2f9e44", + "backgroundColor": "#b2f2bb", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "seed": 1301069471, + "version": 608, + "versionNonce": 97888657, + "isDeleted": false, + "boundElements": [ + { + "type": "text", + "id": "vaFZ4NTM-ynAWN9xIuCgY" + } + ], + "updated": 1704967754619, + "link": null, + "locked": false + }, + { + "id": "vaFZ4NTM-ynAWN9xIuCgY", + "type": "text", + "x": 2169.629310219384, + "y": -3889.9583661144134, + "width": 164.16006469726562, + "height": 45, + "angle": 0, + "strokeColor": "#2f9e44", + "backgroundColor": "#b2f2bb", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": null, + "seed": 1933434481, + "version": 323, + "versionNonce": 719336447, + "isDeleted": false, + "boundElements": null, + "updated": 1704967754619, + "link": null, + "locked": false, + "text": "Container", + "fontSize": 36, + "fontFamily": 1, + "textAlign": "center", + "verticalAlign": "top", + "baseline": 31, + "containerId": "ZlhzvaNeHw2kG3j_U_BVL", + "originalText": "Container", + "lineHeight": 1.25 + }, + { + "id": "heCWfyZvSZk60i37Hqy9u", + "type": "text", + "x": 1974.7092204977048, + "y": -3757.9583966319915, + "width": 548.4375, + "height": 345.59999999999997, + "angle": 0, + "strokeColor": "#1e1e1e", + "backgroundColor": "#b2f2bb", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": null, + "seed": 368949983, + "version": 373, + "versionNonce": 269198047, + "isDeleted": false, + "boundElements": null, + "updated": 1704967668686, + "link": null, + "locked": false, + "text": "├── app\n│   ├── log\n│   │   └── api-server.log\n│   ├── main.py\n│   ├── Makefile\n│   ├── requirements.txt\n│   └── run.sh\n", + "fontSize": 36, + "fontFamily": 3, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 337, + "containerId": null, + "originalText": "├── app\n│   ├── log\n│   │   └── api-server.log\n│   ├── main.py\n│   ├── Makefile\n│   ├── requirements.txt\n│   └── run.sh\n", + "lineHeight": 1.2 + }, + { + "id": "-tLQEKRzDtXgk6i7UC4CJ", + "type": "text", + "x": 1367.7094036031733, + "y": -3958.9584576671477, + "width": 79.66802978515625, + "height": 45, + "angle": 0, + "strokeColor": "#1971c2", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": null, + "seed": 1494085855, + "version": 22, + "versionNonce": 1108579263, + "isDeleted": false, + "boundElements": null, + "updated": 1704967718404, + "link": null, + "locked": false, + "text": "Host", + "fontSize": 36, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 31, + "containerId": null, + "originalText": "Host", + "lineHeight": 1.25 + }, + { + "id": "OXdl7yMrTwt_w2o5BD9xR", + "type": "rectangle", + "x": 2893.7093120504387, + "y": -3855.9584652965423, + "width": 461.00006103515716, + "height": 211.0000228881836, + "angle": 0, + "strokeColor": "#f08c00", + "backgroundColor": "#ffc9c9", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "seed": 868345649, + "version": 40, + "versionNonce": 1538938207, + "isDeleted": false, + "boundElements": [ + { + "type": "text", + "id": "IK6b1cadktRnvijOBY-A_" + } + ], + "updated": 1704967771734, + "link": null, + "locked": false + }, + { + "id": "IK6b1cadktRnvijOBY-A_", + "type": "text", + "x": 3052.0473247457517, + "y": -3772.9584538524505, + "width": 144.32403564453125, + "height": 45, + "angle": 0, + "strokeColor": "#f08c00", + "backgroundColor": "#ffc9c9", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": null, + "seed": 1222697521, + "version": 27, + "versionNonce": 1749250239, + "isDeleted": false, + "boundElements": null, + "updated": 1704967794238, + "link": null, + "locked": false, + "text": "/tmp/log", + "fontSize": 36, + "fontFamily": 1, + "textAlign": "center", + "verticalAlign": "middle", + "baseline": 31, + "containerId": "OXdl7yMrTwt_w2o5BD9xR", + "originalText": "/tmp/log", + "lineHeight": 1.25 } ], "appState": {