Skip to content

Instantly share code, notes, and snippets.

@calvin-puram
Created March 31, 2022 14:36
Show Gist options
  • Select an option

  • Save calvin-puram/eb0e24e9b1bb5cee55cef33421dcf049 to your computer and use it in GitHub Desktop.

Select an option

Save calvin-puram/eb0e24e9b1bb5cee55cef33421dcf049 to your computer and use it in GitHub Desktop.
FROM ubuntu:18.04 as build
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Etx/UTC
# Add required binaries to ubuntu image
RUN apt-get update -qq && apt-get install -y \
git \
cmake \
g++ \
pkg-config \
libssl-dev \
curl \
llvm \
clang \
musl-dev \
binutils-dev \
libcurl4-openssl-dev \
zlib1g-dev \
libdw-dev \
libiberty-dev \
gcc \
python \
docker.io \
protobuf-compiler \
cargo \
awscli \
&& rm -rf /var/lib/apt/lists/*
# Create a new empty shell project
RUN USER=root cargo new --bin /faucet
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN curl https://sh.rustup.rs -sSf | \
sh -s -- -y --no-modify-path --default-toolchain none
RUN rustup install stable \
nightly
RUN rustup default stable && rustup target add wasm32-unknown-unknown --toolchain nightly
WORKDIR /faucet
# Copy our manifests
COPY runtime/ .
COPY frame/ .
COPY utils/common/ ./utils/
COPY utils/faucet-server/Cargo.toml ./utils/faucet-server/Cargo.toml
# Copy the source code
COPY ./utils/faucet-server/src ./utils/faucet-server/src
# Remove previous faucet binaries
#RUN rm ./target/release/deps/faucet*
# Build for release.
RUN cargo build --release
RUN cp ./target/release/faucet /tmp/
# The final base image
FROM debian:buster-slim
# Expose ports
EXPOSE 8080
# Install Dependencies
RUN apt-get update -qq && apt-get install -y \
libssl-dev ca-certificates \
wget \
&& rm -rf /var/lib/apt/lists/*
# Copy faucet binary from build
COPY --from=build /tmp/faucet usr/local/bin
# Run the faucet binary
ENTRYPOINT [ "faucet" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment