Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file mounts (work dir change) and python reloading #311

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

services:
vote:
build: ./vote
# use python rather than gunicorn for local dev
command: python app.py
build:
context: ./vote
target: dev
depends_on:
redis:
condition: service_healthy
Expand All @@ -17,7 +17,7 @@ services:
retries: 3
start_period: 10s
volumes:
- ./vote:/app
- ./vote:/usr/local/app
ports:
- "5000:80"
networks:
Expand All @@ -32,7 +32,7 @@ services:
db:
condition: service_healthy
volumes:
- ./result:/app
- ./result:/usr/local/app
ports:
- "5001:80"
- "127.0.0.1:9229:9229"
Expand Down
16 changes: 13 additions & 3 deletions vote/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Using official python runtime base image
FROM python:3.11-slim
# Define a base stage that uses the official python runtime base image
FROM python:3.11-slim AS base

# add curl for healthcheck
# Add curl for healthcheck
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -13,6 +13,16 @@ WORKDIR /usr/local/app
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Define a stage specifically for development, where it'll watch for
# filesystem changes
FROM base AS dev
RUN pip install watchdog
ENV FLASK_ENV=development
CMD ["python", "app.py"]

# Define the final stage that will bundle the application for production
FROM base AS final

# Copy our code from the current folder to the working directory inside the container
COPY . .

Expand Down