From 035e3c5b4354cc3d945260a8202a8fcc98c7c2c9 Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Tue, 5 Jul 2022 11:58:31 -0400 Subject: [PATCH] fastapi: add dev envs support Signed-off-by: Milas Bowman --- fastapi/.docker/docker-compose.yaml | 13 +++++++++++++ fastapi/Dockerfile | 23 +++++++++++++++++++---- fastapi/README.md | 9 +++++++++ fastapi/compose.yaml | 5 +++-- 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 fastapi/.docker/docker-compose.yaml diff --git a/fastapi/.docker/docker-compose.yaml b/fastapi/.docker/docker-compose.yaml new file mode 100644 index 0000000..d4f2188 --- /dev/null +++ b/fastapi/.docker/docker-compose.yaml @@ -0,0 +1,13 @@ +services: + api: + build: + context: . + target: dev-envs + container_name: fastapi-application + environment: + PORT: 8000 + ports: + - '8000:8000' + volumes: + - /var/run/docker.sock:/var/run/docker.sock + restart: "no" diff --git a/fastapi/Dockerfile b/fastapi/Dockerfile index 5b5bf8c..ec2aa35 100644 --- a/fastapi/Dockerfile +++ b/fastapi/Dockerfile @@ -1,11 +1,26 @@ -FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-slim +# syntax = docker/dockerfile:1.4 + +FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-slim AS builder WORKDIR /app -RUN apt update - COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install -r requirements.txt COPY ./app ./app +FROM builder as dev-envs + +RUN <