flask: dev envs support & misc improvements (#263)
* Docker Desktop Development Environments config * Use cache volumes for pip * Upgrade from Python 3.7 -> Python 3.10 * Use port `8000` to avoid conflicts with Airplay on macOS for default Flask port `5000` * Use `SIGINT` to gracefully stop Flask Signed-off-by: Milas Bowman <milas.bowman@docker.com>master
parent
457fe0e668
commit
ec552567c7
@ -0,0 +1,10 @@
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: app
|
||||
target: dev-envs
|
||||
stop_signal: SIGINT
|
||||
ports:
|
||||
- '8000:8000'
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
@ -1,7 +1,27 @@
|
||||
FROM python:3.7-alpine
|
||||
WORKDIR /app
|
||||
# syntax=docker/dockerfile:1.4
|
||||
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt /app
|
||||
RUN pip3 install -r requirements.txt --no-cache-dir
|
||||
COPY . /app
|
||||
ENTRYPOINT ["python3"]
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
COPY . /app
|
||||
|
||||
ENTRYPOINT ["python3"]
|
||||
CMD ["app.py"]
|
||||
|
||||
FROM builder as dev-envs
|
||||
|
||||
RUN <<EOF
|
||||
apk update
|
||||
apk add git
|
||||
EOF
|
||||
|
||||
RUN <<EOF
|
||||
addgroup -S docker
|
||||
adduser -S --shell /bin/bash --ingroup docker vscode
|
||||
EOF
|
||||
# install Docker tools (cli, buildx, compose)
|
||||
COPY --from=gloursdocker/docker / /
|
||||
|
@ -1,5 +1,10 @@
|
||||
services:
|
||||
web:
|
||||
build: app
|
||||
ports:
|
||||
- '5000:5000'
|
||||
build:
|
||||
context: app
|
||||
target: builder
|
||||
# flask requires SIGINT to stop gracefully
|
||||
# (default stop signal from Compose is SIGTERM)
|
||||
stop_signal: SIGINT
|
||||
ports:
|
||||
- '8000:8000'
|
||||
|
Loading…
Reference in New Issue