From f716bfb3826983688528359500d51dfa9c7d54ec Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Tue, 12 Jul 2022 12:18:35 +0200 Subject: [PATCH] add configuration to use django sample with Docker Dev Environments feature (#252) Signed-off-by: Guillaume Lours --- django/.docker/docker-compose.yaml | 9 +++++++++ django/README.md | 7 +++++++ django/app/Dockerfile | 18 +++++++++++++++++- django/compose.yaml | 4 +++- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 django/.docker/docker-compose.yaml diff --git a/django/.docker/docker-compose.yaml b/django/.docker/docker-compose.yaml new file mode 100644 index 0000000..1f340f8 --- /dev/null +++ b/django/.docker/docker-compose.yaml @@ -0,0 +1,9 @@ +services: + web: + build: + context: app + target: dev-envs + ports: + - '8000:8000' + volumes: + - /var/run/docker.sock:/var/run/docker.sock \ No newline at end of file diff --git a/django/README.md b/django/README.md index 2a18733..16a5cc3 100644 --- a/django/README.md +++ b/django/README.md @@ -50,3 +50,10 @@ Stop and remove the containers ``` $ docker compose down ``` +## Use with Docker Development Environments + +You can use this sample with the Dev Environments feature of Docker Desktop. +To develop directly the web service inside a container, you just need to use the https git url of the sample: +`https://github.com/docker/awesome-compose/tree/master/django` + +![page](../dev-envs.png) \ No newline at end of file diff --git a/django/app/Dockerfile b/django/app/Dockerfile index a86ae9c..bdf66f1 100644 --- a/django/app/Dockerfile +++ b/django/app/Dockerfile @@ -1,4 +1,6 @@ -FROM python:3.7-alpine +# syntax=docker/dockerfile:1.4 + +FROM --platform=$BUILDPLATFORM python:3.7-alpine AS builder EXPOSE 8000 WORKDIR /app COPY requirements.txt /app @@ -6,3 +8,17 @@ RUN pip3 install -r requirements.txt --no-cache-dir COPY . /app ENTRYPOINT ["python3"] CMD ["manage.py", "runserver", "0.0.0.0:8000"] + +FROM builder as dev-envs +RUN <