-
Notifications
You must be signed in to change notification settings - Fork 11
/
Standalone.Dockerfile
59 lines (44 loc) · 1.68 KB
/
Standalone.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
# Use a specific version tag for the alpine base image
FROM rust:1 AS base
# Install required packages
RUN apt-get update && \
apt-get install --yes git python3 python3-pip pkg-config clang curl libssl-dev llvm libudev-dev libgmp3-dev protobuf-compiler libc6 && \
rm -rf /var/lib/apt/lists/*
# Create a non-root user to run
RUN adduser --uid 1000 --ingroup users --disabled-password --gecos "" --home /webb webb \
&& mkdir -p /data /webb/.local/share/webb \
&& chown -R webb:users /data /webb/.local/share/webb \
&& ln -s /data /webb/.local/share/webb
# Set the user and working directory
USER webb
WORKDIR /webb
# Use a multi-stage build to reduce the size of the final image
FROM rust:1 AS builder
# Install required packages
RUN apt-get update && \
apt-get install -y git python3 python3-pip pkg-config clang curl libssl-dev llvm libudev-dev libgmp3-dev protobuf-compiler libc6 && \
rm -rf /var/lib/apt/lists/*
RUN pip3 install dvc
# Copy the source code into the container
WORKDIR /webb
COPY . .
# Use "RUN" instructions to combine multiple commands into a single layer
RUN dvc pull -v \
&& RUST_BACKTRACE=1 cargo build --release -p webb-standalone-node --verbose
# Use the final stage to reduce the size of the final image
FROM base
# Create the /data directory and set permissions
USER root
RUN mkdir -p /data \
&& chown webb:users /data
USER webb
# Copy the binary into the final image
COPY --from=builder /webb/target/release/webb-standalone-node /usr/local/bin
# Expose ports and volume
EXPOSE 30333 9933 9944 9615 33334
VOLUME ["/data"]
# Set the user and working directory
USER webb
WORKDIR /webb
# Sanity check
CMD ["/usr/local/bin/webb-standalone-node", "--version"]