diff --git a/.gitignore b/.gitignore index f37e98458..12ded7917 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ build/ coverage.xml dist/ docs/_build +node_modules/ venv*/ env/ *egg-info/ @@ -19,4 +20,4 @@ env/ # Personnal .env -c_pytest.py \ No newline at end of file +c_pytest.py diff --git a/Dockerfile b/Dockerfile index 150b9d4de..334bda156 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,45 @@ -FROM python:3.7 +FROM ghcr.io/foundry-rs/foundry:nightly as foundry -# Set up code directory -RUN mkdir -p /usr/src/app -WORKDIR /usr/src/app +FROM python:3.9 # Install linux dependencies -RUN apt-get update \ - && apt-get install -y libssl-dev npm +RUN --mount=type=cache,target=/var/lib/apt/lists \ + apt-get update \ + && apt-get install --no-install-recommends -y curl libssl-dev + +# install node v18 for ganache and hardhat +# c22ac94432765ecaa9b4c462b9a7f8dd509071da is v8.2.0 +RUN --mount=type=cache,target=/root/.cache \ + curl -L https://raw.githubusercontent.com/tj/n/c22ac94432765ecaa9b4c462b9a7f8dd509071da/bin/n -o /usr/local/bin/n \ + && chmod 755 /usr/local/bin/n \ + && n 18 \ + && npm set cache /root/.cache/npm --global \ + && npm install -g npm@latest + +# install ganache +RUN --mount=type=cache,target=/root/.cache \ + npm install --verbose --global "ganache@7.2.0" + +# (hardhat is installed with npx if needed) -RUN npm install n -g \ - && npm install -g npm@latest -RUN npm install -g ganache +# prepare python dependencies +ENV PIP_NO_WARN_ABOUT_ROOT_USER 0 +RUN --mount=type=cache,target=/root/.cache \ + pip install --upgrade pip setuptools wheel +# install anvil +COPY --from=foundry /usr/local/bin/anvil /usr/local/bin/ + +# install python dependencies +WORKDIR /usr/src/app COPY requirements.txt . -COPY requirements-dev.txt . +RUN --mount=type=cache,target=/root/.cache \ + pip install -r requirements.txt -RUN pip install -r requirements.txt -RUN pip install -r requirements-dev.txt +COPY requirements-dev.txt . +RUN --mount=type=cache,target=/root/.cache \ + pip install -r requirements-dev.txt +# Set up code directory +# use docker volumes to mount brownie's code at /code WORKDIR /code diff --git a/docker-compose.yml b/docker-compose.yml index d279801d1..b1b562484 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,6 @@ services: context: . volumes: - .:/code - command: tail -f /dev/null \ No newline at end of file + command: tail -f /dev/null + # TODO: load this from an environment variable so M1 macs can easily use this + platform: linux/x86_64