Skip to content

Commit 7e0f6fb

Browse files
committed
adding Dockerfile to build from local source and extend README
1 parent fded8c8 commit 7e0f6fb

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ubuntu:focal
2+
3+
# Generic packages
4+
RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install -y \
5+
cmake \
6+
curl \
7+
git \
8+
libboost-filesystem-dev \
9+
libboost-program-options-dev \
10+
libboost-system-dev \
11+
libboost-test-dev \
12+
python3-pip \
13+
software-properties-common \
14+
unzip \
15+
wget
16+
17+
# Python dependencies
18+
RUN pip3 install psutil
19+
20+
# CVC4
21+
RUN curl --silent "https://api.github.com/repos/CVC4/CVC4/releases/latest" | grep browser_download_url | grep -E 'linux' | cut -d '"' -f 4 | wget -qi - -O /usr/local/bin/cvc4 \
22+
&& chmod a+x /usr/local/bin/cvc4
23+
24+
# Z3
25+
RUN curl --silent "https://api.github.com/repos/Z3Prover/z3/releases/latest" | grep browser_download_url | grep -E 'ubuntu' | cut -d '"' -f 4 | wget -qi - -O z3.zip \
26+
&& unzip -p z3.zip '*bin/z3' > /usr/local/bin/z3 \
27+
&& chmod a+x /usr/local/bin/z3
28+
29+
# Get .NET
30+
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
31+
&& dpkg -i packages-microsoft-prod.deb \
32+
&& apt update \
33+
&& apt install -y apt-transport-https \
34+
&& apt update \
35+
&& apt install -y dotnet-sdk-3.1
36+
37+
# Get boogie
38+
RUN dotnet tool install --global boogie
39+
ENV PATH="${PATH}:/root/.dotnet/tools"
40+
41+
# Copy solidity sourcecode, instead of cloning it
42+
RUN mkdir solidity
43+
COPY . solidity
44+
45+
RUN cd solidity \
46+
&& mkdir -p build \
47+
&& cd build \
48+
&& cmake -DUSE_Z3=Off -DUSE_CVC4=Off .. \
49+
&& make \
50+
&& make install
51+
52+
# Set entrypoint
53+
ENTRYPOINT ["solc-verify.py"]

docker/README.md

+57-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,70 @@
22

33
This Dockerfile allows to quickly try solc-verify using [Docker](https://docs.docker.com/).
44

5-
The Dockerfile can be built with the following command:
5+
The Dockerfile can be built with one of the following commands:
6+
7+
## Build from Open Source
8+
9+
The following Dockerfile will clone the latest solitidy version from GitHub. This is useful if you only have the solc-verify Dockerfile, but not the sourcecode itself.
10+
611
```
712
docker build -t solc-verify -f Dockerfile-solcverify.src .
813
```
914

15+
## Build locally
16+
17+
Building locally is useful, if you are working on a local copy of solc-verify or in a CI pipeline.
18+
19+
```
20+
# go back to solidity root folder
21+
cd ..
22+
23+
# build docker image
24+
docker build -t solc-verify -f docker/Dockerfile-solcverify-local.src .
25+
```
26+
27+
# Verify Contracts
28+
29+
## Use `runsv.sh` script
30+
1031
The included `runsv.sh` script can be used run the containerized solc-verify on programs residing on the host:
1132
```
1233
./runsv.sh Contract.sol [FLAGS]
1334
```
1435

36+
> Example: `./runsv.sh ../test/solc-verify/examples/Annotations.sol`
37+
38+
## Directly use docker commands to verify contracts
39+
40+
### Validate sample contract
41+
42+
Verify that the docker image is functioning correctly by validating one of the built in contracts. The following command instantiates the SOLC-Verify image, verifies a contract and then shuts down again:
43+
44+
```bash
45+
PATH_TO_SAMPLE_CONTRACT=/solidity/test/solc-verify/examples/Annotations.sol
46+
docker run --rm solc-verify:latest $PATH_TO_SAMPLE_CONTRACT
47+
```
48+
49+
The command should return following messages:
50+
51+
```
52+
C::add: OK
53+
C::[implicit_constructor]: OK
54+
C::[receive_ether_selfdestruct]: OK
55+
Use --show-warnings to see 1 warning.
56+
No errors found.
57+
```
58+
59+
### Validate your contracts
60+
61+
To validate your own contracts place them in a directory that can be mounted into a running container of SOLC-Verify. All you need is the absolute path to the location, where the contracts are located. The following command will mount the contracts located in `$PATH_TO_CONTRACTS` into a running docker container of SOLC-verify and will then validate the contract with the name `$CONTRACT_NAME`.
62+
63+
64+
```bash
65+
PATH_TO_CONTRACTS= # path where the contracts are located on the machine running the docker image
66+
CONTRACT_NAME= # name of the contract to be validated
67+
68+
docker run --rm -v $PATH_TO_CONTRACTS:/contracts solc-verify:latest /contracts/$CONTRACT_NAME
69+
```
70+
1571
For more information on running solc-verify and examples, see [SOLC-VERIFY-README.md](../SOLC-VERIFY-README.md).

0 commit comments

Comments
 (0)