Skip to content

Commit

Permalink
chore: 🤖 add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatpotato13 committed Mar 7, 2023
1 parent f649c37 commit 2f74d1e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.github
.vscode
scripts
target
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM ubuntu:jammy AS builder

# The node will be built in this directory
WORKDIR /infra-did-substrate

RUN apt -y update && \
apt install -y --no-install-recommends \
software-properties-common llvm curl git file binutils binutils-dev \
make cmake ca-certificates clang g++ zip dpkg-dev openssl gettext \
build-essential pkg-config libssl-dev libudev-dev time clang protobuf-compiler

# install rustup
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

# rustup directory
ENV PATH /root/.cargo/bin:$PATH

# setup rust nightly channel, pinning specific version as newer versions have a regression
RUN rustup install nightly

RUN rustup install stable

# install wasm toolchain for substrate
RUN rustup target add wasm32-unknown-unknown --toolchain nightly

#compiler ENV
ENV CC clang
ENV CXX g++

# Copy code to build directory, instead of only using .dockerignore, we copy elements
# explicitly. This lets us cache build results while iterating on scripts.
COPY . .

# Pass the features while building image as `--build-arg features='--features mainnet'` or `--build-arg features='--features testnet'`
ARG features
ARG release

RUN if [ "$release" = "Y" ] ; then \
echo 'Building in release mode.' ; \
WASM_BUILD_TOOLCHAIN=nightly cargo build --profile=release $features ; \
mv /infra-did-substrate/target/release/infradid /infra-did-substrate/target/; \
else \
echo 'Building in production mode.' ; \
WASM_BUILD_TOOLCHAIN=nightly cargo build --profile=production $features ; \
mv /infra-did-substrate/target/production/infradid /infra-did-substrate/target/; \
fi

# Final stage. Copy the node executable and the script
FROM ubuntu:jammy

WORKDIR /infra-did-substrate

COPY --from=builder /infra-did-substrate/target/infradid .

# curl is required for uploading to keystore
# note: `subkey insert` is a potential alternarve to curl
RUN apt -y update \
&& apt install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*

# expose node ports
EXPOSE 30333 9933 9944

ENV RUST_BACKTRACE 1

ENTRYPOINT ["./infradid"]
CMD []

0 comments on commit 2f74d1e

Please sign in to comment.