Skip to content

Commit 3ac4e60

Browse files
committed
🏗️ build(ats): add Dockerfile for coverage execution
- use node:24.13.0 as base image - install system dependencies for solc (libusb, libudev) - copy and install root and contracts workspace dependencies - create directories for hardhat cache and artifacts - switch to hardhatuser for parallel coverage execution - run coverage with npx hardhat Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
1 parent 7f3f75e commit 3ac4e60

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Use an official Node runtime as a parent image
2+
FROM node:24.13.0
3+
4+
# Install dependencies for native solc (glibc etc)
5+
RUN apt-get update && apt-get install -y libusb-1.0-0-dev libudev-dev && rm -rf /var/lib/apt/lists/*
6+
7+
# Set the working directory in the container
8+
WORKDIR /usr/src/app
9+
10+
# Copy monorepo configuration
11+
COPY package*.json ./
12+
13+
# Copy workspace package.json files for better caching
14+
COPY packages/ats/contracts/package*.json ./packages/ats/contracts/
15+
16+
# Install dependencies (using workspaces)
17+
# We use --include-workspace-root to ensure root devDependencies are available
18+
# We install all dependencies because workers will need full node_modules
19+
RUN npm ci --include-workspace-root --ignore-scripts
20+
21+
# Create directories for Hardhat cache and artifacts to ensure they are writeable
22+
RUN mkdir -p packages/ats/contracts/cache packages/ats/contracts/artifacts packages/ats/contracts/typechain-types
23+
24+
# Copy the rest of the application code
25+
COPY . .
26+
27+
# Build the contracts and generate types if needed
28+
WORKDIR /usr/src/app/packages/ats/contracts
29+
RUN npm i
30+
# Ensure global HOME is set and writeable for .coverage_parallel_temp
31+
ENV HOME=/usr/src/app
32+
RUN npm run compile
33+
34+
# Add these lines before the RUN npm run compile command
35+
RUN useradd -m hardhatuser && \
36+
chown -R hardhatuser /usr/src/app && \
37+
chown -R hardhatuser /usr/src/app/packages/ats/contracts
38+
39+
USER hardhatuser
40+
41+
# Set the working directory again after switching user
42+
WORKDIR /usr/src/app/packages/ats/contracts
43+
44+
# The command to run parallel coverage
45+
CMD ["npx", "hardhat", "coverage"]

0 commit comments

Comments
 (0)