-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.rust
More file actions
69 lines (61 loc) · 3.16 KB
/
Dockerfile.rust
File metadata and controls
69 lines (61 loc) · 3.16 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
# syntax=docker/dockerfile:1.4
# deva.sh - Rust Developer Image
# Extends main deva image with Rust toolchain and ecosystem tools
ARG BASE_IMAGE=ghcr.io/thevibeworks/deva:latest
FROM ${BASE_IMAGE}
LABEL org.opencontainers.image.title="deva-rust"
LABEL org.opencontainers.image.description="Rust development environment with full toolchain"
ARG RUST_TOOLCHAINS="stable"
ARG RUST_TARGETS="wasm32-unknown-unknown"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV RUSTUP_HOME=/opt/rustup \
CARGO_HOME=/opt/cargo \
PATH=/opt/cargo/bin:$PATH
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -y --no-install-recommends \
libpq-dev postgresql-client \
libmysqlclient-dev mysql-client \
libsqlite3-dev sqlite3 \
libssl-dev \
libcurl4-openssl-dev \
libpng-dev libjpeg-dev \
libudev-dev \
libproc2-dev \
libzmq3-dev libzmq5 libczmq-dev && \
curl -fsSL 'https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key' | gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg && \
ARCH=$(dpkg --print-architecture) && \
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=${ARCH}] https://packages.clickhouse.com/deb stable main" > /etc/apt/sources.list.d/clickhouse.list && \
apt-get update && \
apt-get install -y --no-install-recommends clickhouse-client
RUN --mount=type=cache,target=/tmp/rust-cache,sharing=locked \
set -euxo pipefail && \
mkdir -p "$RUSTUP_HOME" "$CARGO_HOME" && \
mkdir -p "$CARGO_HOME/registry/cache" "$CARGO_HOME/registry/index" "$CARGO_HOME/git" && \
chown -R "$DEVA_UID:$DEVA_GID" "$RUSTUP_HOME" "$CARGO_HOME" && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain none --profile default && \
rustup toolchain install ${RUST_TOOLCHAINS} && \
for tc in ${RUST_TOOLCHAINS}; do \
rustup component add --toolchain "$tc" rustfmt clippy rust-analyzer; \
done && \
if [ -n "${RUST_TARGETS}" ]; then \
for tc in ${RUST_TOOLCHAINS}; do \
rustup target add --toolchain "$tc" ${RUST_TARGETS}; \
done; \
fi && \
rustup default stable && \
chown -R "$DEVA_UID:$DEVA_GID" "$RUSTUP_HOME" "$CARGO_HOME"
RUN echo 'export PATH="/opt/cargo/bin:$PATH"' >> "$DEVA_HOME/.zshrc" && \
echo 'export RUSTUP_HOME=/opt/rustup' >> "$DEVA_HOME/.zshrc" && \
echo 'export CARGO_HOME=/opt/cargo' >> "$DEVA_HOME/.zshrc" && \
sed -i 's/plugins=(git docker python golang node npm aws/plugins=(git docker python golang rust node npm aws/' "$DEVA_HOME/.zshrc" && \
echo '# Rust aliases' >> "$DEVA_HOME/.zshrc" && \
echo 'alias cr="cargo run"' >> "$DEVA_HOME/.zshrc" && \
echo 'alias cb="cargo build"' >> "$DEVA_HOME/.zshrc" && \
echo 'alias ct="cargo test"' >> "$DEVA_HOME/.zshrc" && \
echo 'alias cc="cargo check"' >> "$DEVA_HOME/.zshrc" && \
echo 'alias cw="cargo watch -x check -x test -x run"' >> "$DEVA_HOME/.zshrc" && \
echo 'alias cf="cargo fmt"' >> "$DEVA_HOME/.zshrc" && \
echo 'alias cl="cargo clippy"' >> "$DEVA_HOME/.zshrc"