forked from automata-network/automata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
61 lines (44 loc) · 1.86 KB
/
Dockerfile
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
# syntax=docker/dockerfile:experimental
FROM rust:1.50 as builder
LABEL maintainer "Automata Team"
ARG PROFILE=release
ARG TOOLCHAIN=nightly-2021-06-16
RUN apt-get update && \
apt-get install -y build-essential pkg-config llvm-dev libclang-dev clang libssl-dev curl
RUN rustup toolchain install ${TOOLCHAIN} && \
rustup default ${TOOLCHAIN} && \
rustup target add wasm32-unknown-unknown --toolchain ${TOOLCHAIN}
ARG SCCACHE_TAR_URL=https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz
RUN curl -LsSf ${SCCACHE_TAR_URL} > /tmp/sccache.tar.gz && \
tar axvf /tmp/sccache.tar.gz --strip-components=1 -C /usr/local/bin --wildcards --no-anchored 'sccache' && \
chmod +x /usr/local/bin/sccache && \
sccache --version && \
rm -rf /tmp/sccache.tar.gz
ENV RUSTC_WRAPPER=/usr/local/bin/sccache
ENV CARGO_INCREMENTAL=0
ENV SCCACHE_CACHE_SIZE=1G
WORKDIR /automata
COPY . /automata
ARG FEATURES=finitestate
RUN --mount=type=cache,target=/root/.cache/sccache \
--mount=type=cache,target=/usr/local/cargo/registry/index \
--mount=type=cache,target=/usr/local/cargo/registry/cache \
--mount=type=cache,target=/usr/local/cargo/git/db \
cargo build --$PROFILE --bin automata --features $FEATURES && \
cp /automata/target/${PROFILE}/automata /usr/local/bin/automata
# ===== SECOND STAGE ======
FROM debian:buster-slim as app
LABEL maintainer "Automata Team"
COPY --from=builder /automata/scripts/run-node.sh /run-node.sh
COPY --from=builder /usr/local/bin/automata /usr/local/bin/automata
RUN apt-get update && \
apt-get install -y curl
RUN useradd -m -u 1000 -U -s /bin/sh -d /automata automata && \
mkdir -p /automata/.local/share/automata && \
chown -R automata:automata /automata/.local && \
ln -s /automata/.local/share/automata /data
USER automata
EXPOSE 30333 9933 9944
VOLUME ["/data"]
ENTRYPOINT ["/run-node.sh"]
CMD []