-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (71 loc) · 2.65 KB
/
Dockerfile
File metadata and controls
84 lines (71 loc) · 2.65 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Use an official Python image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install dependencies for objcopy, picotool, and pico-sdk
# libopencv-dev and onward are for gerborlyze (SmartPanelizer)
RUN apt-get update && apt-get install -y \
binutils \
build-essential \
cmake \
git \
libusb-1.0-0-dev \
pkg-config \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
libopencv-dev \
libpugixml-dev \
libpangocairo-1.0-0 \
libpango1.0-dev \
libcairo2-dev \
clang \
make \
python3 \
git \
python3-wheel \
curl \
python3-pip \
python3-venv \
cargo \
&& rm -rf /var/lib/apt/lists/*
# Install gerborlyze (SmartPanelizer)
RUN pip3 install --user git+https://git.jaseg.de/pcb-tools-extension.git
RUN python3 -m pip install svg-flatten-wasi==3.1.6
RUN cargo install usvg --version 0.34.1
# Clone pico-sdk and picotool, then build picotool with PICO_SDK_PATH, then remove pico-sdk
RUN git clone --depth=1 https://github.com/raspberrypi/pico-sdk.git /pico-sdk && \
git clone https://github.com/raspberrypi/picotool.git picotool && \
cd picotool && mkdir build && cd build && \
cmake .. -DPICO_SDK_PATH=/pico-sdk && \
make && \
cd /app && rm -rf /pico-sdk
# Copy just requirements.txt first to leverage Docker layer cache
COPY requirements.txt .
# Install dependencies — cached unless requirements.txt changes
RUN pip install --no-cache-dir -r requirements.txt
# Copy all your files into the container
# Place this as low in the file as possible since calling this invalidates the docker layer cache
COPY . .
# Expose the port the server runs on
EXPOSE 3333
# Try to fix print()s not showing up immediately in the logs
ENV PYTHONUNBUFFERED=1
# Ensure user-level pip bin (svg-flatten-wasi) is on PATH
ENV PATH="/root/.local/bin:${PATH}"
# Flask: Run the app (dev)
# Set environment variables
# ENV FLASK_APP=app.py
# ENV FLASK_RUN_HOST=0.0.0.0
# -u for unbuffered output, so print statements appear in real-time
# CMD ["python3", "-u", "server.py"]
# Gunicorn: Run the app (production)
# gunicorn server:app --workers 1 --bind 0.0.0.0:8000 --timeout 300
# Only one worker process to avoid concurrency issues (since we're writing files, can't be concurrent)
CMD ["gunicorn", "server:app", "--workers", "4", "--bind", "0.0.0.0:3333", "--capture-output", "--log-level", "debug"]
# To run the gitub built container image locally, do:
#docker pull ghcr.io/devices-lab/makedevice-backend:latest
#docker run -p 3333:3333 ghcr.io/devices-lab/makedevice-backend:latest
# To get requirements.txt with the bare minimum, do:
# pip install pipreqs
# pipreqs . --force