forked from docker/awesome-compose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flask-redis: dev envs support & misc improvements (docker#265)
(Most of this is almost identical to docker#263.) * Docker Desktop Development Environments config * Use cache volumes for pip * Downgrade from Python 3.11 _alpha_ -> Python 3.10 * Use port `8000` to avoid conflicts with Airplay on macOS for default Flask port `5000` * Use `SIGINT` to gracefully stop Flask * Formatting fixes in `compose.yaml` Signed-off-by: Milas Bowman <[email protected]>
- Loading branch information
Showing
5 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
services: | ||
redis: | ||
image: redislabs/redismod | ||
ports: | ||
- '6379:6379' | ||
web: | ||
build: | ||
context: . | ||
target: dev-envs | ||
stop_signal: SIGINT | ||
ports: | ||
- '8000:8000' | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
depends_on: | ||
- redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
FROM python:3.11.0a6-alpine3.15 | ||
# syntax=docker/dockerfile:1.4 | ||
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder | ||
|
||
WORKDIR /code | ||
|
||
COPY requirements.txt /code | ||
RUN pip install -r requirements.txt --no-cache-dir | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
pip3 install -r requirements.txt | ||
|
||
COPY . /code | ||
CMD python app.py | ||
|
||
ENTRYPOINT ["python3"] | ||
CMD ["app.py"] | ||
|
||
FROM builder as dev-envs | ||
|
||
RUN <<EOF | ||
apk update | ||
apk add git bash | ||
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 / / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
services: | ||
redis: | ||
image: redislabs/redismod | ||
ports: | ||
- '6379:6379' | ||
web: | ||
build: . | ||
ports: | ||
- "5000:5000" | ||
volumes: | ||
- .:/code | ||
depends_on: | ||
- redis | ||
redis: | ||
image: redislabs/redismod | ||
ports: | ||
- '6379:6379' | ||
web: | ||
build: | ||
context: . | ||
target: builder | ||
# flask requires SIGINT to stop gracefully | ||
# (default stop signal from Compose is SIGTERM) | ||
stop_signal: SIGINT | ||
ports: | ||
- '8000:8000' | ||
volumes: | ||
- .:/code | ||
depends_on: | ||
- redis |