הרצת תמונות עם ספריות python עם docker compose
-
יש לי כמה docker images מוכנים שעלי להריץ עם docker compose.
התמונות כבר לאחר בניה- כך שאין לי אפשרות להוסיף את התעודה דרך ה- dockerfile.
ניסיתי להכניס את פקודות ההתקנה ב- entrypoint או ב- cmd, וזה עזר לחלק מהשגיאות, אבל לפי השגיאות הנותרות נראה שהבעיה היא עם ספריות python שכנראה זקוקות להתקנה משלהם.האם מישהו התנסה בסיטואציה מעין זו או קרוב לכך ויוכל לכוון אותי לפתרון?
ושאלה נוספת:
האם מבחינה טכנית יש אפשרות לבקש ממערכת הפניות להחריג את תעבורת הרשת של docker דרך ה-VPN של החברה במקום ה-VPN של wifree3?מצרפת את קובץ ה- docker compose:
version: '3.8' services: postgres: image: postgres:latest container_name: postgres environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: pass POSTGRES_DB: postgres ports: - "5432:5432" redis: image: <redis-image> container_name: redis ports: - "6379:6379" fastapi: image: <fast-api-image> container_name: fastapi entrypoint: sh -c "apt-get update && apt-get install -y curl ca-certificates python3-pip && \ pip install certifi && \ (curl -sL https://netfree.link/dl/unix-ca.sh | sh) && \ cat /etc/ssl/certs/ca-certificates.crt >> $(python3 -c 'import certifi; print(certifi.where())') && \ cp /etc/ssl/certs/ca-certificates.crt /etc/ca-bundle.crt && \ export NODE_EXTRA_CA_CERTS=/etc/ca-bundle.crt && \ export REQUESTS_CA_BUNDLE=/etc/ca-bundle.crt && \ export SSL_CERT_FILE=/etc/ca-bundle.crt && \ /app/entrypoint.sh" ports: - "8001:8001" environment: - UVICORN_LOG_LEVEL=trace - NODE_EXTRA_CA_CERTS=/etc/ca-bundle.crt - REQUESTS_CA_BUNDLE=/etc/ca-bundle.crt - SSL_CERT_FILE=/etc/ca-bundle.crt env_file: - .env depends_on: - postgres - redis multi-agent:<multi-agent-image> container_name: multi-agent command: sh -c "apt-get update && apt-get install -y curl ca-certificates python3-pip && \ pip install certifi && \ (curl -sL https://netfree.link/dl/unix-ca.sh | sh) && \ cat /etc/ssl/certs/ca-certificates.crt >> $(python3 -c 'import certifi; print(certifi.where())') && \ cp /etc/ssl/certs/ca-certificates.crt /etc/ca-bundle.crt && \ export NODE_EXTRA_CA_CERTS=/etc/ca-bundle.crt && \ export REQUESTS_CA_BUNDLE=/etc/ca-bundle.crt && \ export SSL_CERT_FILE=/etc/ca-bundle.crt && \ uvicorn app.main_service:app --host 0.0.0.0 --port 8002 --loop asyncio" ports: - "8002:8002" environment: - NODE_EXTRA_CA_CERTS=/etc/ca-bundle.crt - REQUESTS_CA_BUNDLE=/etc/ca-bundle.crt - SSL_CERT_FILE=/etc/ca-bundle.crt env_file: - .env depends_on: - postgres - redis
אלו השגיאות המופיעות ב fastapi ו-multi-agent:
eption multi-agent | raise caught_exception multi-agent | File "/usr/local/lib/python3.10/site-packages/botocore/endpoint.py", line 279, in _do_get_response multi-agent | http_response = self._send(request) multi-agent | File "/usr/local/lib/python3.10/site-packages/botocore/endpoint.py", line 383, in _send multi-agent | return self.http_session.send(request) multi-agent | File "/usr/local/lib/python3.10/site-packages/botocore/httpsession.py", line 491, in send multi-agent | raise SSLError(endpoint_url=request.url, error=e) multi-agent | botocore.exceptions.SSLError: SSL validation failed for https://logs.eu-west-1.amazonaws.com/ [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)
אשמח לכל עזרה והכוונה. תודה!
-
@racheld
הבעיה נפתרה.
מצרפת פתרון למקרה שיזדקקו לו אחרים.
יש להוסיף ל docker compose פקודה הדורסת את פקודת העליה של האפליקציה שרצה ב-image הספציפי. ( במקרה שלי command ו- entrypoint)
(ניתן לבדוק זאת ב inspect ב- docker desktop)
בפקודת העליה של הדוקר לשים את הפקודות הבאות ולשרשר אליהן את פקודת העליה של האפליקציה עצמה ( במקרה שלי:/app/entrypoint.sh
) :entrypoint: sh -c " apt-get update && apt-get install -y curl ca-certificates python3-pip && \ pip install certifi && \ export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt && \ curl -sL https://netfree.link/dl/unix-ca.sh | sh && \ update-ca-certificates && \ python3 -c 'import certifi; print(certifi.where())' && \ cp /etc/ssl/certs/ca-certificates.crt $(python3 -c 'import certifi; print(certifi.where())') && \ export NODE_EXTRA_CA_CERTS=$(python3 -c 'import certifi; print(certifi.where())') && \ export REQUESTS_CA_BUNDLE=$(python3 -c 'import certifi; print(certifi.where())') && \ export SSL_CERT_FILE=$(python3 -c 'import certifi; print(certifi.where())') && \ /app/entrypoint.sh "
בהצלחה!