From 2711b48d0279ff52307238fd1a2c690840c0de98 Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Thu, 4 Aug 2022 14:27:50 +0200 Subject: [PATCH] Integrate compiler download into Dockerfile (#1) --- .devcontainer/scripts/get_solidity.py | 2 ++ .gitignore | 2 ++ Dockerfile | 46 ++++++++++++++++----------- brownie-config.yaml | 6 +++- 4 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 .devcontainer/scripts/get_solidity.py diff --git a/.devcontainer/scripts/get_solidity.py b/.devcontainer/scripts/get_solidity.py new file mode 100644 index 0000000..21f9ca8 --- /dev/null +++ b/.devcontainer/scripts/get_solidity.py @@ -0,0 +1,2 @@ +from brownie.project.compiler import install_solc +install_solc("0.7.2", "0.8.2", "0.8.15") diff --git a/.gitignore b/.gitignore index 898188a..6542b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ __pycache__ .hypothesis/ build/ reports/ + +.DS_Store diff --git a/Dockerfile b/Dockerfile index 4b17565..5c43068 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ # source for this dockerfile: https://github.com/eth-brownie/brownie -FROM python:3.7 +FROM python:3.10 + +EXPOSE 8000 # Set up code directory RUN mkdir -p /usr/src/app/brownie-setup WORKDIR /usr/src/app # Install linux dependencies -RUN apt-get update && apt-get install -y libssl-dev -RUN apt-get update && apt-get install -y npm +RUN apt-get update && apt-get install -y libssl-dev npm # Install Ganache chain RUN npm install --global ganache-cli @@ -16,31 +17,38 @@ RUN npm install --global ganache-cli RUN echo force-brownie-upgrade-0 RUN wget https://raw.githubusercontent.com/eth-brownie/brownie/master/requirements.txt -RUN pip install -r requirements.txt -RUN pip install eth-brownie +RUN pip install -r requirements.txt \ + && pip install eth-brownie \ + && pip install fastapi \ + && pip install uvicorn -# Install FastAPI -RUN pip install fastapi -RUN pip install uvicorn +# Add some aliases +RUN echo "alias rm='rm -i'" >> /root/.bashrc \ + && echo "alias l='ls -CF'" >> /root/.bashrc \ + && echo "alias la='ls -A'" >> /root/.bashrc \ + && echo "alias ll='ls -alF'" >> /root/.bashrc # force installation of solc in docker image # solc version is defined in brownie-config.yaml WORKDIR /usr/src/app/brownie-setup RUN echo force-dependency-upgrade-0 -RUN brownie init -f -COPY brownie-config.yaml /usr/src/app/brownie-setup -COPY contracts/DummyNFT.sol /usr/src/app/brownie-setup/contracts -RUN brownie compile --all +# download required solidity compiler +COPY .devcontainer/scripts/get_solidity.py . +RUN python get_solidity.py -EXPOSE 8000 - -# Add some aliases -RUN echo "alias rm='rm -i'" >> /root/.bashrc -RUN echo "alias l='ls -CF'" >> /root/.bashrc -RUN echo "alias la='ls -A'" >> /root/.bashrc -RUN echo "alias ll='ls -alF'" >> /root/.bashrc +# Initialize dummy project, copy brownie-config for dependencies and compile to download all dependencies +COPY brownie-config.yaml /usr/src/app/brownie-setup +RUN brownie init dummy \ + && cd dummy \ + && cp ../brownie-config.yaml . \ + && brownie compile --all \ + && cd ../../ WORKDIR /projects +# Install starship.rs prompt +RUN curl -fsSL https://starship.rs/install.sh | sh -s -- --yes +RUN echo "eval \"\$(starship init bash)\"" >> ~/.bashrc && echo "eval \"\$(starship init zsh)\"" >> ~/.zshrc + CMD [ "bash" ] \ No newline at end of file diff --git a/brownie-config.yaml b/brownie-config.yaml index 5777011..cc57e72 100644 --- a/brownie-config.yaml +++ b/brownie-config.yaml @@ -2,15 +2,19 @@ compiler: evm_version: null solc: - version: 0.8.2 + #version: 0.8.15 optimizer: enabled: true runs: 200 remappings: - "@openzeppelin=OpenZeppelin/openzeppelin-contracts@4.7.0" + - "@chainlink=smartcontractkit/chainlink@1.6.0" + - "@etherisc/gif-interface=etherisc/gif-interface@2.0.0-staging-n" vyper: version: null dependencies: # github dependency format: /@ - OpenZeppelin/openzeppelin-contracts@4.7.0 + - smartcontractkit/chainlink@1.6.0 + - etherisc/gif-interface@2.0.0-staging-n