Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

dev: Package app into a container

Clémence Lesné9b2c71dd95a1
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f854141
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,36 @@
+# Base container
+FROM docker.io/library/python:3.11-slim-bullseye@sha256:9f35f3a6420693c209c11bba63dcf103d88e47ebe0b205336b5168c122967edf AS base
+
+# Build container
+FROM base AS build
+
+RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked --mount=target=/root/.cache/pip,type=cache,sharing=locked \
+ apt-get update \
+ && apt-get install --yes gcc python3-dev \
+ && python3 -m pip install --upgrade pip setuptools wheel
+
+RUN python -m venv /venv
+ENV PATH=/venv/bin:$PATH
+
+COPY requirements.txt .
+RUN --mount=target=/root/.cache/pip,type=cache,sharing=locked \
+ python3 -m pip install --requirement requirements.txt
+
+# Output container
+FROM base
+
+ARG VERSION
+ENV VERSION=${VERSION}
+
+RUN useradd -m appuser \
+ && mkdir /app \
+ && chown -R appuser:appuser /app
+
+USER appuser
+
+COPY --from=build /venv /venv
+ENV PATH=/venv/bin:$PATH
+
+COPY --chown=appuser:appuser . /app
+
+CMD ["bash", "-c", "cd /app && uvicorn main:api --host 0.0.0.0 --port 8080 --proxy-headers --no-server-header --timeout-keep-alive 60 --header x-version:${VERSION}"]
diff --git a/Makefile b/Makefile
index 7509458..c154530 100644
--- a/Makefile
+++ b/Makefile
@@ -50,3 +50,11 @@ start:
--port 8080 \
--proxy-headers \
--reload
+
+
+build:
+ $(docker) build \
+ --build-arg VERSION=$(version_full) \
+ --tag $(container_name):$(version_small) \
+ --tag $(container_name):latest \
+ .