Skip to content

Commit 121ba0d

Browse files
committed
added gunicorn for prod deployment
1 parent b151286 commit 121ba0d

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

app/Dockerfile

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1-
# Stage 1: Build dependencies
1+
# Stage 1: Build Python dependencies
22
FROM python:3.10-alpine AS build
3-
COPY requirements.txt .
3+
WORKDIR /api/app
4+
5+
# Install build dependencies for psycopg2
6+
RUN apk add --no-cache gcc musl-dev postgresql-dev
7+
8+
# Copy requirements and install dependencies
9+
COPY requirements.txt ./
410
RUN pip install --user --no-cache-dir -r requirements.txt \
5-
&& find /root/.local -name '*.pyc' -delete \
6-
&& find /root/.local -name '__pycache__' -delete
11+
&& find /root/.local -name '*.pyc' -delete \
12+
&& find /root/.local -name '__pycache__' -delete
713

8-
# Stage 2: Main app
14+
# Stage 2: Main application image
915
FROM python:3.10-alpine AS main
10-
WORKDIR /app
16+
WORKDIR /api
17+
18+
# Install PostgreSQL client for pg_isready
19+
RUN apk add --no-cache postgresql-client
20+
21+
# Copy installed Python packages from build stage
1122
COPY --from=build /root/.local /root/.local
12-
COPY . .
23+
24+
# Copy the entire app folder
25+
COPY . ./app
26+
27+
# Add pip binaries to PATH
1328
ENV PATH=/root/.local/bin:$PATH
14-
ENV FLASK_APP=wsgi.py
29+
ENV FLASK_APP=app/wsgi.py
30+
31+
# Expose port
1532
EXPOSE 5000
1633

17-
# Use Gunicorn instead of Flask dev server
18-
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app", "--workers", "2"]
34+
# Start Gunicorn server
35+
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app.wsgi:app", "--workers", "2"]

0 commit comments

Comments
 (0)