-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
50 lines (41 loc) · 1.36 KB
/
Dockerfile.dev
File metadata and controls
50 lines (41 loc) · 1.36 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
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
# System packages for building Rust projects and general development
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
ca-certificates \
curl \
make \
pkg-config \
build-essential \
gcc \
g++ \
musl-tools \
musl-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN { id -u amux >/dev/null 2>&1 \
|| useradd -m -s /bin/bash -d /home/amux amux 2>/dev/null \
|| useradd -s /bin/bash -d /home/amux amux ; } \
&& mkdir -p /workspace /home/amux \
&& chown -R amux:amux /workspace /home/amux
USER amux
# Install Rust via rustup (stable toolchain)
ENV RUSTUP_HOME=/home/amux/.rustup \
CARGO_HOME=/home/amux/.cargo \
PATH=/home/amux/.cargo/bin:/home/amux/.local/bin:$PATH
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain stable --profile default && \
rustup component add clippy rustfmt rust-analyzer && \
rustup target add x86_64-unknown-linux-musl
# Pre-fetch and cache dependencies by building a dummy project first
# This layer is invalidated only when Cargo.toml changes
WORKDIR /workspace
COPY Cargo.toml ./
RUN mkdir -p src && \
echo 'fn main() {}' > src/main.rs && \
echo '' > src/lib.rs && \
cargo fetch && \
rm -rf src
COPY . .
CMD ["/bin/bash"]