Skip to content

Instantly share code, notes, and snippets.

@deuszx
Created February 20, 2024 14:23
Show Gist options
  • Save deuszx/53830666791ef79c39b665c9806de965 to your computer and use it in GitHub Desktop.
Save deuszx/53830666791ef79c39b665c9806de965 to your computer and use it in GitHub Desktop.
FROM docker.io/bitnami/minideb:bullseye
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
RUST_VERSION=1.70.0
ARG TOOLCHAIN=stable \
COMPILER_TAG=v2.1.0 \
NIGHTLY=nightly-x86_64-unknown-linux-gnu
LABEL RUST_VERSION=1.70.0 \
TOOLCHAIN=stable \
COMPILER_TAG=v3.2.0
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl gnupg netbase wget \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get install -y --no-install-recommends git mercurial openssh-client subversion procps \
&& rm -rf /var/lib/apt/lists/*
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends autoconf automake bzip2 dpkg-dev file g++ gcc imagemagick libbz2-dev libc6-dev libcurl4-openssl-dev libdb-dev libevent-dev libffi-dev libgdbm-dev libglib2.0-dev libgmp-dev libjpeg-dev libkrb5-dev liblzma-dev libmagickcore-dev libmagickwand-dev libmaxminddb-dev libncurses5-dev libncursesw5-dev libpng-dev libpq-dev libreadline-dev libsqlite3-dev libssl-dev libtool libwebp-dev libxml2-dev libxslt-dev libyaml-dev make patch unzip xz-utils zlib1g-dev $( if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then echo 'default-libmysqlclient-dev'; else echo 'libmysqlclient-dev'; fi ) \
&& rm -rf /var/lib/apt/lists/*
RUN set -eux; dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='f21c44b01678c645d8fbba1e55e4180a01ac5af2d38bcbd14aa665e0d96ed69a' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e7b0f47557c1afcd86939b118cbcf7fb95a5d1d917bdd355157b63ca00fc4333' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
&& url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \
&& wget "$url"; \
&& echo "${rustupSha256} *rustup-init" | sha256sum -c - \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch} \
&& rm rustup-init; chmod -R a+w $RUSTUP_HOME $CARGO_HOME; rustup --version; cargo --version; rustc --version;
WORKDIR /app
RUN rustup toolchain install $TOOLCHAIN \
RUN apt update -y
RUN apt install clang -y
RUN rustup toolchain install nightly
RUN rustup component add rust-src
RUN rustup component add rust-src --toolchain $NIGHTLY
RUN cargo install --locked --git https://github.com/paritytech/cargo-contract --tag $COMPILER_TAG
RUN apt clean
RUN rm -rf /var/lib/apt/lists/*
WORKDIR /builds
ENV CARGO_TARGET_DIR=/target
RUN cargo contract new contract
RUN cd contract \
&& cargo contract build
RUN rm -rf /target/ink/contract.json
RUN rm -rf /builds/contract/*
WORKDIR /builds/contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment