This commit is contained in:
Eden Kirin
2024-01-11 12:11:37 +01:00
parent f09a149ee5
commit 7a458790d2
5 changed files with 286 additions and 95 deletions

5
api-server/.dockerignore Normal file
View File

@ -0,0 +1,5 @@
**/.env/
**/__pycache__/
**/Makefile
**/Dockerfile
*.log

View File

@ -6,14 +6,13 @@ ENV \
EXPOSE 3000 EXPOSE 3000
WORKDIR /app WORKDIR /app
COPY ./app . COPY ./app .
RUN \ RUN \
python -m venv /venv && \ python -m venv /venv && \
pip install -r requirements.txt pip install -r requirements.txt
WORKDIR /app
# start shell script when container starts # start shell script when container starts
ENTRYPOINT ["/app/run.sh"] ENTRYPOINT ["/app/run.sh"]

View File

@ -4,6 +4,7 @@ CONTAINER_NAME=api-server
build: clean build: clean
@docker build \ @docker build \
--progress=plain \ --progress=plain \
--no-cache \
--tag $(IMAGE_NAME) \ --tag $(IMAGE_NAME) \
. .
@ -12,8 +13,19 @@ run:
--name $(IMAGE_NAME) \ --name $(IMAGE_NAME) \
--publish 3000:3000 \ --publish 3000:3000 \
--env CONTAINER_NAME="Awesome API server" \ --env CONTAINER_NAME="Awesome API server" \
--detach \
$(CONTAINER_NAME) $(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: clean:
- @docker stop $(CONTAINER_NAME) - @docker stop $(CONTAINER_NAME)
- @docker rm $(CONTAINER_NAME) - @docker rm $(CONTAINER_NAME)

View File

@ -18,7 +18,11 @@ async def root():
def main(): 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}") logging.info(f"Starting server {CONTAINER_NAME}")

View File

@ -3,6 +3,35 @@
"version": 2, "version": 2,
"source": "https://excalidraw.com", "source": "https://excalidraw.com",
"elements": [ "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", "id": "qrvX2_Ljra-KNVEIIh3RE",
"type": "rectangle", "type": "rectangle",
@ -143,81 +172,11 @@
"originalText": "Layer ", "originalText": "Layer ",
"lineHeight": 1.2 "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", "id": "BRqzl1Zr6eYvXrUFQRvxI",
"type": "rectangle", "type": "rectangle",
"x": 856.6536276428862, "x": 854.6536581604644,
"y": -4447.958628904674, "y": -4533.958613645885,
"width": 1423.1111653645835, "width": 1423.1111653645835,
"height": 72.75552842881943, "height": 72.75552842881943,
"angle": 0, "angle": 0,
@ -234,8 +193,8 @@
"type": 3 "type": 3
}, },
"seed": 1906323775, "seed": 1906323775,
"version": 664, "version": 710,
"versionNonce": 99977457, "versionNonce": 1610245439,
"isDeleted": false, "isDeleted": false,
"boundElements": [ "boundElements": [
{ {
@ -243,15 +202,15 @@
"id": "C1Xps43QBT_xR_pVjWgV7" "id": "C1Xps43QBT_xR_pVjWgV7"
} }
], ],
"updated": 1704964749025, "updated": 1704969948357,
"link": null, "link": null,
"locked": false "locked": false
}, },
{ {
"id": "C1Xps43QBT_xR_pVjWgV7", "id": "C1Xps43QBT_xR_pVjWgV7",
"type": "text", "type": "text",
"x": 2148.20229300747, "x": 2146.202323525048,
"y": -4433.180864690264, "y": -4519.180849431475,
"width": 126.5625, "width": 126.5625,
"height": 43.199999999999996, "height": 43.199999999999996,
"angle": 0, "angle": 0,
@ -266,11 +225,11 @@
"frameId": null, "frameId": null,
"roundness": null, "roundness": null,
"seed": 480626225, "seed": 480626225,
"version": 641, "version": 687,
"versionNonce": 1904183057, "versionNonce": 1259955551,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": null,
"updated": 1704964812347, "updated": 1704969948357,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "Layer ", "text": "Layer ",
@ -464,8 +423,8 @@
{ {
"id": "aXcQxDqmK_9eZEeocNy0G", "id": "aXcQxDqmK_9eZEeocNy0G",
"type": "text", "type": "text",
"x": 947.5008227267704, "x": 947.5008227267705,
"y": -6301.493121923061, "y": -6301.493121923062,
"width": 173.34005737304688, "width": 173.34005737304688,
"height": 45, "height": 45,
"angle": 0, "angle": 0,
@ -480,11 +439,11 @@
"frameId": null, "frameId": null,
"roundness": null, "roundness": null,
"seed": 886899775, "seed": 886899775,
"version": 602, "version": 606,
"versionNonce": 69594943, "versionNonce": 821675377,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": null,
"updated": 1704965311619, "updated": 1704967250829,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "Dockerfile", "text": "Dockerfile",
@ -1603,7 +1562,7 @@
"x": 882.4316224345532, "x": 882.4316224345532,
"y": -5081.291792695907, "y": -5081.291792695907,
"width": 738.28125, "width": 738.28125,
"height": 734.4, "height": 647.9999999999999,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "#ffc9c9", "backgroundColor": "#ffc9c9",
@ -1616,22 +1575,234 @@
"frameId": null, "frameId": null,
"roundness": null, "roundness": null,
"seed": 2088509169, "seed": 2088509169,
"version": 77, "version": 79,
"versionNonce": 457508977, "versionNonce": 1221365151,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": null,
"updated": 1704964761846, "updated": 1704969941603,
"link": null, "link": null,
"locked": false, "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, "fontSize": 36,
"fontFamily": 3, "fontFamily": 3,
"textAlign": "left", "textAlign": "left",
"verticalAlign": "top", "verticalAlign": "top",
"baseline": 726, "baseline": 639,
"containerId": null, "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 "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": { "appState": {