I am trying to call the OpenAI API from within my docker container but the request is timing out. The same curl works on my machine but not from within my container
I tried running this curl. It worked on the host machine but not in the container.
curl https://api.openai.com/v1/models \
-H 'Authorization: Bearer sk-auth-token' \
-H 'OpenAI-Organization: org-orgid'
Here is my Dockerfile. Please let me know what I am missing here. Also, I'd like to add that I am able to call it sometimes but other times it timeouts.
FROM python:3.12.0a3-alpine3.17 as base
ENV PYTHONDONTWRITEBYTECODE 1
COPY requirements.txt .
RUN apk add --update --no-cache --virtual .build-deps \
build-base \
postgresql-dev \
libffi-dev \
python3-dev \
libffi-dev \
jpeg-dev \
zlib-dev \
musl-dev \
libpq \
&& pip install --no-cache-dir -r requirements.txt \
&& find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' +
# Now multistage builds
FROM python:3.12.0a3-alpine3.17
RUN apk add --update --no-cache libpq libjpeg-turbo
COPY --from=base /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
COPY --from=base /usr/local/bin/ /usr/local/bin/
WORKDIR /app
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONPATH /app:$PYTHONPATH
COPY . /app/