-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (30 loc) · 978 Bytes
/
Dockerfile
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
# Use an official Python runtime as a parent image
FROM python:3.11.2-alpine as builder
# Install build dependencies
RUN apk update && apk add --no-cache \
build-base \
python3-dev \
linux-headers \
i2c-tools-dev
# Set up a virtual environment
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
# Install dependencies from requirements.txt
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Final stage
FROM python:3.11.2-alpine
# Install runtime dependencies only
RUN apk update && apk add --no-cache \
py3-smbus \
i2c-tools
# Copy the virtual environment from the builder stage
COPY --from=builder /venv /venv
ENV PATH="/venv/bin:$PATH"
# Set the working directory and copy application files
WORKDIR /app
COPY . .
# Expose port 5000 for the application
EXPOSE 5000
# Command to run the application using gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--access-logfile", "-", "--log-level", "info", "run:app"]