FROM node:20-bullseye
# Create app directory
WORKDIR /app
# Install system dependencies
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
build-essential \
python3 \
; \
rm -rf /var/lib/apt/lists/*
# Install Bun (JavaScript runtime / package manager used by this project)
ENV BUN_INSTALL=/root/.bun
ENV PATH="$BUN_INSTALL/bin:$PATH"
RUN curl -fsSL https://bun.sh/install | bash
# Verify Bun is installed
RUN bun --version
# Provide default Hardhat environment variables for Hardhat config to enable compilation in the image
ENV HARDHAT_VAR_MNEMONIC="test test test test test test test test test test test junk"
ENV HARDHAT_VAR_INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
ENV MNEMONIC="test test test test test test test test test test test junk"
ENV INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# Copy manifest files first to leverage Docker cache
COPY package.json bun.lockb ./
# Install project dependencies
RUN bun install
# Copy the rest of the source code
COPY . .
# Build the project from source
RUN bun run compile
# Default to a shell for easy experimentation
CMD ["/bin/bash"]