diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9fe342c --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +./target diff --git a/Dockerfile b/Dockerfile index 48fe819..a3a8515 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,15 @@ -FROM --platform=linux/amd64 rust:1.80 as builder +ARG BUILD_PLATFORM=linux/amd64 +ARG RUST_VERSION=1.80 +ARG CARGO_STYLUS_VERSION + +FROM --platform=${BUILD_PLATFORM} rust:${RUST_VERSION} AS builder RUN apt-get update && apt-get install -y git RUN rustup target add x86_64-unknown-linux-gnu -RUN git clone https://github.com/offchainlabs/cargo-stylus.git +ARG CARGO_STYLUS_VERSION +RUN test -n "$CARGO_STYLUS_VERSION" +RUN git clone --branch v$CARGO_STYLUS_VERSION https://github.com/offchainlabs/cargo-stylus.git WORKDIR /cargo-stylus -RUN git checkout v0.5.2 RUN cargo build --release --manifest-path main/Cargo.toml -FROM --platform=linux/amd64 rust:1.80 -COPY --from=builder /cargo-stylus/target/release/cargo-stylus /usr/local/bin/cargo-stylus \ No newline at end of file + +FROM --platform=${BUILD_PLATFORM} rust:${RUST_VERSION} AS cargo-stylus-base +COPY --from=builder /cargo-stylus/target/release/cargo-stylus /usr/local/bin/cargo-stylus diff --git a/Makefile b/Makefile index c63a85a..b4fbed4 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +CARGO_STYLUS_VERSION := $(shell cargo pkgid --manifest-path main/Cargo.toml | cut -d '@' -f 2) + .PHONY: build build: cargo build @@ -17,3 +19,7 @@ lint: .PHONY: install install: fmt lint cargo install --path main + +.PHONY: docker +docker: + docker build -t cargo-stylus-base:$(CARGO_STYLUS_VERSION) --build-arg CARGO_STYLUS_VERSION=$(CARGO_STYLUS_VERSION) .