-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.62 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Development
# docker build -t wally .
# docker run --rm -v $(pwd)/api:/wally/api -v $(pwd)/web:/wally/web -e DEMO=true -p 80:80 wally
# ==============================
# Stage 1: Build Python dependencies
# ==============================
FROM python:3.14-alpine AS builder
# Install build dependencies
RUN apk add --no-cache --virtual .build-deps build-base libffi-dev musl-dev python3-dev
WORKDIR /wally
# Copy requirements
COPY api/requirements.txt .
# Install Python dependencies to a separate location
RUN pip install --no-cache-dir --prefer-binary --upgrade pip setuptools wheel \
&& pip install --no-cache-dir --prefix=/install -r requirements.txt
# Optional: remove tests and unnecessary files from site-packages
RUN find /install/lib/python3.14/site-packages -name "tests" -type d -exec rm -rf {} + \
&& find /install/lib/python3.14/site-packages -name "*.pyc" -delete \
&& find /install/lib/python3.14/site-packages -name "*.pyo" -delete \
&& find /install/lib/python3.14/site-packages -name "*.so" -exec strip --strip-unneeded {} +
# ==============================
# Stage 2: Runtime image
# ==============================
FROM python:3.14-alpine
# Install Nginx runtime
RUN apk add --no-cache nginx
WORKDIR /wally
# Copy Python dependencies from builder
COPY --from=builder /install /usr/local
# Copy app code
COPY api /wally/api
COPY --chown=nginx:nginx web /wally/web
RUN mkdir /wally/data
# Copy Nginx config
COPY nginx.conf /etc/nginx/http.d/default.conf
# Expose ports
EXPOSE 80
# Start FastAPI + Nginx
CMD ["sh", "-c", "python3 -m uvicorn api.main:app --host 0.0.0.0 --port 8000 & nginx -g 'daemon off;'"]