-
Notifications
You must be signed in to change notification settings - Fork 276
/
Dockerfile
64 lines (56 loc) · 1.53 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
62
63
64
# builder stage
FROM rust:slim-bookworm AS builder
WORKDIR /app
# install required packages
RUN apt-get update -y && \
apt-get install -y build-essential mold
RUN rustup toolchain install nightly-2024-09-09
RUN rustup target add wasm32-unknown-unknown
RUN rustup default nightly-2024-09-09
COPY . .
ARG PROFILE="deploy"
ARG RUSTFLAGS=""
ARG FEATURES=""
ARG CARGOFLAGS=""
RUN RUSTFLAGS="${RUSTFLAGS}" mold --run cargo ${CARGOFLAGS} build --profile "${PROFILE}" --features "${FEATURES}"
# final image
FROM debian:bookworm-slim
ARG PROFILE="deploy"
ARG STORAGE=/storage
ARG TARGET_DIR=/app/target/${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"]