forked from hyperledger-iroha/iroha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.glibc
68 lines (61 loc) · 1.77 KB
/
Dockerfile.glibc
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
# base stage
FROM debian:bookworm-slim AS builder
# install required packages
RUN apt-get update -y && \
apt-get install -y curl build-essential mold pkg-config libssl-dev
# set up Rust toolchain
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup toolchain install nightly-2024-04-18
RUN rustup default nightly-2024-04-18
RUN rustup target add wasm32-unknown-unknown
RUN rustup component add rust-src
# builder stage
WORKDIR /iroha
COPY . .
ARG PROFILE="deploy"
ARG RUSTFLAGS=""
ARG FEATURES=""
ARG CARGOFLAGS=""
RUN RUSTFLAGS="${RUSTFLAGS}" mold --run cargo ${CARGOFLAGS} build --target x86_64-unknown-linux-gnu --profile "${PROFILE}" --features "${FEATURES}"
# final image
FROM debian:bookworm-slim
ARG PROFILE="deploy"
ARG STORAGE=/storage
ARG TARGET_DIR=/iroha/target/x86_64-unknown-linux-gnu/${PROFILE}
ENV BIN_PATH=/usr/local/bin/
ENV CONFIG_DIR=/config
ENV KURA_STORE_DIR=$STORAGE
ENV SNAPSHOT_STORE_DIR=$STORAGE/snapshot
ENV WASM_DIRECTORY=/app/.cache/wasmtime
ENV USER=iroha
ENV UID=1001
ENV GID=1001
RUN <<EOT
set -ex
apt-get update -y && \
apt-get install -y curl ca-certificates jq
addgroup --gid $GID $USER &&
adduser \
--disabled-password \
--gecos "" \
--home /app \
--ingroup "$USER" \
--no-create-home \
--uid "$UID" \
"$USER"
mkdir -p $CONFIG_DIR
mkdir -p $STORAGE
mkdir -p $WASM_DIRECTORY
chown $USER:$USER $STORAGE
chown $USER:$USER $WASM_DIRECTORY
chown $USER:$USER $CONFIG_DIR
EOT
COPY --from=builder $TARGET_DIR/irohad $BIN_PATH
COPY --from=builder $TARGET_DIR/iroha $BIN_PATH
COPY --from=builder $TARGET_DIR/kagami $BIN_PATH
COPY defaults/genesis.json $CONFIG_DIR
COPY defaults/executor.wasm $CONFIG_DIR
COPY defaults/client.toml $CONFIG_DIR
USER $USER
CMD ["irohad"]