Skip to content

Commit

Permalink
chore: development container for hardhat and foundry-rs (#53)
Browse files Browse the repository at this point in the history
* prettier for solidity
* required tooling on startup

closes #52
  • Loading branch information
jac18281828 authored Sep 14, 2023
1 parent 26f9cae commit bce3a25
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 127 deletions.
26 changes: 26 additions & 0 deletions packages/did-eth-registry/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
8 changes: 8 additions & 0 deletions packages/did-eth-registry/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
cache/
artifacts/
lib/
build/
typechain/
typechain-types/
dist/
19 changes: 17 additions & 2 deletions packages/did-eth-registry/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,20 @@
"printWidth": 120,
"singleQuote": true,
"trailingComma": "es5",
"semi": false
}
"semi": false,
"plugins": [
"prettier-plugin-solidity"
],
"overrides": [
{
"files": "*.sol",
"options": {
"tabWidth": 4,
"semi": true,
"singleQuote": false,
"useTabs": false,
"bracketSpacing": true
}
}
]
}
67 changes: 67 additions & 0 deletions packages/did-eth-registry/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM debian:stable-slim as python-builder

# python3.10 is required for node-gyp

RUN export DEBIAN_FRONTEND=noninteractive && \
apt update && \
apt install -y -q --no-install-recommends \
npm build-essential curl \
ca-certificates apt-transport-https \
libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev \
libc6-dev libbz2-dev libffi-dev zlib1g-dev \
python3-pip python3-dev && \
apt clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /build
ADD https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz Python-3.10.13.tgz
RUN tar -xvf Python-3.10.13.tgz
WORKDIR /build/Python-3.10.13
RUN ./configure --enable-optimizations
RUN make -j4

FROM ghcr.io/xmtp/foundry:latest

RUN useradd --create-home -s /bin/bash did
RUN usermod -a -G sudo did
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Python 3.10

COPY --from=python-builder /build /build
WORKDIR /build/Python-3.10.13
RUN make install
RUN which python3 && python3 --version
RUN rm -rf /build

RUN mkdir -p /usr/local/nvm
ENV NVM_DIR=/usr/local/nvm

ENV NODE_VERSION=v14.21.3

ADD https://raw.githubusercontent.com/creationix/nvm/master/install.sh /usr/local/etc/nvm/install.sh
RUN bash /usr/local/etc/nvm/install.sh && \
bash -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default"

ENV NVM_NODE_PATH ${NVM_DIR}/versions/node/${NODE_VERSION}
ENV NODE_PATH ${NVM_NODE_PATH}/lib/node_modules
ENV PATH ${NVM_NODE_PATH}/bin:$PATH

RUN npm install [email protected] -g
RUN npm install yarn -g

ARG PROJECT=did-eth
WORKDIR /workspaces/${PROJECT}

RUN chown -R did:did /workspaces
COPY --chown=did:did . .

# build and test
RUN yarn install --frozen-lockfile
RUN yarn prettier:check
RUN yarn lint
RUN yarn build
RUN yarn test

USER did
Loading

0 comments on commit bce3a25

Please sign in to comment.