-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile.build
60 lines (51 loc) · 1.75 KB
/
Dockerfile.build
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
# syntax=docker/dockerfile:1
#
# Dockerfile with everything needed for local development
# and creating a base image for production builds
FROM debian:buster-slim AS sccache
ARG SCCACHE_VERSION=0.2.15
ADD https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz /tmp
RUN set -eux \
&& tar -zxvf /tmp/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -C /tmp \
&& mv /tmp/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl /opt/sccache \
&& chmod +x /opt/sccache/sccache \
&& touch /opt/sccache/config
FROM rust:1.55-slim-buster AS build
# non-root user
ARG USERNAME=anmol
ARG USER_UID=1000
ARG USER_GID=$USER_UID
WORKDIR /build
# install tools and dependencies
RUN set -eux \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
ca-certificates \
clang \
cmake \
curl \
git \
libssl-dev \
libssl1.1 \
libudev-dev \
llvm \
pkg-config \
&& apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" \
&& apt-get autoremove -y \
&& apt-get clean \
&& unset DEBIAN_FRONTEND \
&& find /var/lib/apt/lists/ -type f -not -name lock -delete \
# Add user
&& useradd -u ${USER_UID} -U -m ${USERNAME} \
&& chown -R ${USERNAME}:${USERNAME} . \
# Install Rust components
&& rustup update nightly \
&& rustup target add wasm32-unknown-unknown --toolchain nightly \
&& rustup default stable \
&& rustup component add rustfmt
ENV RUSTC_WRAPPER=/usr/local/bin/sccache
COPY --from=sccache /opt/sccache/sccache $RUSTC_WRAPPER
COPY --from=sccache --chown=${USERNAME}:${USERNAME} /opt/sccache/config /home/${USERNAME}/.config/sccache/config
USER ${USERNAME}:${USERNAME}