Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Use cache volume #476

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .github/workflows/compiler_docker.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
env:
DOCKER_PORT: 4000

- name: Sleep for 120s, allow Docker image to boot up
- name: Sleep for 300s, allow Docker image to boot up
uses: juliangruber/sleep-action@v1
with:
time: 120s
time: 300s

- name: Install docker-tests
run: yarn workspace docker-tests install
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ jobs:
- name: Build
run: cargo build --verbose
- name: Pull docker image
run: docker pull docker.io/achimcc/ink-compiler:latest
run: docker pull docker.io/paritytech/ink-ci-linux:production
- name: Tag docker image
run: docker tag docker.io/achimcc/ink-compiler:latest ink-compiler
run: docker tag docker.io/paritytech/ink-ci-linux:production ink-compiler
- name: Copy contract folder
run: mkdir ./builds && cp -R crates/contract ./builds/contract
- name: pre-build compilation cache
run: docker run --volume cache:/usr/local/cargo/registry --volume ${GITHUB_WORKSPACE}/builds:/builds --workdir /builds/contract/ ink-compiler cargo contract build --release
- name: Run tests
run: cargo test --workspace --exclude rust_analyzer_wasm --verbose
83 changes: 52 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ RUN apt-get --yes install docker-ce docker-ce-cli \
COPY sysbox/on-start.sh /usr/bin
RUN chmod +x /usr/bin/on-start.sh

RUN mkdir /builds
COPY crates/contract /builds/contract

# Entrypoint

ENTRYPOINT [ "on-start.sh" ]
17 changes: 0 additions & 17 deletions Dockerfile.compiler

This file was deleted.

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ docker-shell:
--runtime=sysbox-runc \
-it \
--volume /tmp:/tmp \
--volume cache:/cache \
--entrypoint /bin/bash \
--publish $(DOCKER_PORT):4000 \
--publish 5000:4000 \
ink-playground

docker-log:
Expand Down
11 changes: 4 additions & 7 deletions crates/contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
[package]
name = "contract"
version = "4.0.0-alpha.3"
version = "4.0.0-beta"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
publish = false

[dependencies]
ink = { version = "4.0.0-alpha.3", default-features = false }
ink = { version = "4.0.0-beta", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }

[lib]
name = "contract"
path = "lib.rs"
crate-type = [
# Used for normal contract Wasm blobs.
"cdylib",
]
crate-type = ["cdylib"]

[features]
default = ["std"]
Expand Down
6 changes: 5 additions & 1 deletion crates/sandbox/src/build_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ fn build_basic_secure_docker_command() -> Command {
DOCKER_WORKDIR,
"--net",
"none",
"--volume",
"cache:/usr/local/cargo/registry:ro",
"--volume",
"/builds:/builds",
"--memory",
"1024m",
"--memory-swap",
Expand Down Expand Up @@ -131,7 +135,7 @@ fn build_execution_command() -> Vec<String> {
"rm -rf {}/contract.* {}/metadata.json",
target_dir, target_dir
);
let build_cmd = "cargo contract build --offline 2>&1".to_string();
let build_cmd = "cargo contract build --release --offline 2>&1".to_string();
let move_cmd = format!("mv {}/contract.contract {}", target_dir, DOCKER_OUTPUT);

let command = format!("{} && {} && {}", clean_cmd, build_cmd, move_cmd);
Expand Down
7 changes: 5 additions & 2 deletions sysbox/on-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ dockerd > /var/log/dockerd.log 2>&1 &
sleep 2

# pull inner images
docker pull achimcc/ink-compiler:latest
docker tag achimcc/ink-compiler ink-compiler
docker pull paritytech/ink-ci-linux:production
docker tag paritytech/ink-ci-linux:production ink-compiler

docker run --volume cache:/usr/local/cargo/registry --volume /builds:/builds --workdir /builds/contract/ ink-compiler cargo clean
docker run --volume cache:/usr/local/cargo/registry --volume /builds:/builds --workdir /builds/contract/ ink-compiler cargo contract build --release
docker run --volume cache:/usr/local/cargo/registry --volume /builds:/builds --workdir /builds/contract/ ink-compiler cargo contract test
# start backend server
/app/target/release/backend --port 4000 --host 0.0.0.0 --frontend_folder /app/packages/playground/dist