File tree Expand file tree Collapse file tree 4 files changed +44
-6
lines changed
Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Original file line number Diff line number Diff line change 1+ services :
2+ api :
3+ build :
4+ context : .
5+ target : dev-envs
6+ container_name : fastapi-application
7+ environment :
8+ PORT : 8000
9+ ports :
10+ - ' 8000:8000'
11+ volumes :
12+ - /var/run/docker.sock:/var/run/docker.sock
13+ restart : " no"
Original file line number Diff line number Diff line change 1- FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-slim
1+ # syntax = docker/dockerfile:1.4
22
3- WORKDIR /app
3+ FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-slim AS builder
44
5- RUN apt update
5+ WORKDIR /app
66
77COPY requirements.txt ./
8- RUN pip install --no-cache-dir -r requirements.txt
8+ RUN --mount=type=cache,target=/root/.cache/pip \
9+ pip install -r requirements.txt
910
1011COPY ./app ./app
1112
13+ FROM builder as dev-envs
14+
15+ RUN <<EOF
16+ apt-get update
17+ apt-get install -y --no-install-recommends git
18+ EOF
19+
20+ RUN <<EOF
21+ useradd -s /bin/bash -m vscode
22+ groupadd docker
23+ usermod -aG docker vscode
24+ EOF
25+ # install Docker tools (cli, buildx, compose)
26+ COPY --from=gloursdocker/docker / /
Original file line number Diff line number Diff line change @@ -52,4 +52,13 @@ Stop and remove the containers
5252$ docker compose down
5353```
5454
55+ ## Use with Docker Development Environments
5556
57+ You can use this sample with the Dev Environments feature of Docker Desktop.
58+
59+ ![ Screenshot of creating a Dev Environment in Docker Desktop] ( ../dev-envs.png )
60+
61+ To develop directly on the services inside containers, use the HTTPS Git url of the sample:
62+ ```
63+ https://github.com/docker/awesome-compose/tree/master/fastapi
64+ ```
Original file line number Diff line number Diff line change 11services :
22 api :
3- build : .
3+ build :
4+ context : .
5+ target : builder
46 container_name : fastapi-application
57 environment :
68 PORT : 8000
79 ports :
810 - ' 8000:8000'
911 restart : " no"
10-
You can’t perform that action at this time.
0 commit comments