-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.77 KB
/
Dockerfile
File metadata and controls
56 lines (42 loc) · 1.77 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
# Dockerfile - build MS4000 firmware.bin
# Author: (mon7gomery)
FROM debian:stable-slim
WORKDIR /home/builder/workspace
# Python i/o should be unbuffered for tooling to work properly:
ENV PYTHONUNBUFFERED=1
# Fallback default - should be set with --build-arg UID=/GID= in the Makefile
ARG UID=1000
ARG GID=1000
# Create user/group
RUN groupadd -g $GID buildergroup \
&& useradd -u $UID -g buildergroup -m builder \
&& groupadd -f dialout \
&& usermod -aG dialout builder \
&& chown builder:buildergroup /home/builder
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests \
make git rsync curl ca-certificates protobuf-compiler build-essential \
&& rm -rf /var/lib/apt/lists/*
# Switch to non-root user early
USER builder
# Install mise
RUN curl -fsSL https://mise.run | bash
ENV PATH="/home/builder/.local/bin:/home/builder/.local/share/mise/shims:$PATH"
# install toolchains using mise
COPY --chown=builder:buildergroup mise.toml ./
RUN mise trust && mise install && mise reshim
# install python dependecies
COPY --chown=$UID:$GID ./firmware/requirements.txt ./firmware/requirements.txt
RUN python -m pip install --upgrade pip
RUN python -m pip install -r ./firmware/requirements.txt
# mise runtime PATH setup
ENV PATH="/home/builder/.local/share/mise/installs/python/latest/bin:$PATH"
# Now copy source code (this layer will invalidate most often) ===
COPY --chown=$UID:$GID ./ ./
# Build webapp
RUN cd web/app && make deps
# Build steps (these will only re-run if the code above them changed)
RUN cd firmware/ && make
# Optional: clean up as root if needed (but consider leaving build artifacts if you mount volumes)
#USER root
# RUN rm -rf ./* # <-- usually not needed when you mount -v $(PWD):/home/builder/workspace