Skip to content

Commit

Permalink
Integrate compiler download into Dockerfile (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
doerfli committed Aug 4, 2022
1 parent 8c10ac2 commit 2711b48
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .devcontainer/scripts/get_solidity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from brownie.project.compiler import install_solc
install_solc("0.7.2", "0.8.2", "0.8.15")
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ __pycache__
.hypothesis/
build/
reports/

.DS_Store
46 changes: 27 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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" ]
6 changes: 5 additions & 1 deletion brownie-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]"
- "@chainlink=smartcontractkit/[email protected]"
- "@etherisc/gif-interface=etherisc/[email protected]"
vyper:
version: null

dependencies:
# github dependency format: <owner>/<repository>@<release>
- OpenZeppelin/[email protected]
- smartcontractkit/[email protected]
- etherisc/[email protected]

0 comments on commit 2711b48

Please sign in to comment.