diff --git a/.github/workflows/build_and_push_image.yml b/.github/workflows/build_and_push_image.yml index 1400aaf..87d6292 100644 --- a/.github/workflows/build_and_push_image.yml +++ b/.github/workflows/build_and_push_image.yml @@ -25,10 +25,19 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + - name: Build and push fork image uses: docker/build-push-action@v6.1.0 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: ghcr.io/lidofinance/hardhat-node:${{ github.ref_name }} + + - name: Build and push scratch image + uses: docker/build-push-action@v6.1.0 + with: + context: . + file: scratch.Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/lidofinance/hardhat-node:${{ github.ref_name }}-scratch diff --git a/hardhat.config.scratch.ts b/hardhat.config.scratch.ts new file mode 100644 index 0000000..db9193a --- /dev/null +++ b/hardhat.config.scratch.ts @@ -0,0 +1,17 @@ +import "dotenv/config"; +import { HardhatUserConfig } from "hardhat/config"; +import "@nomicfoundation/hardhat-ethers"; + +const config: HardhatUserConfig = { + solidity: "0.8.23", + networks: { + hardhat: { + initialBaseFeePerGas: 0, + accounts: { + count: 10, + }, + chainId: 1, + }, + }, +}; +export default config; diff --git a/scratch.Dockerfile b/scratch.Dockerfile new file mode 100644 index 0000000..74b485c --- /dev/null +++ b/scratch.Dockerfile @@ -0,0 +1,40 @@ +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/go/dockerfile-reference/ + +# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 + +ARG NODE_VERSION=lts +ARG PNPM_VERSION=9.11.0 + +FROM node:${NODE_VERSION}-alpine + +# Use production node environment by default. +ENV NODE_ENV=production + +# Install pnpm. +RUN --mount=type=cache,target=/root/.npm \ + npm install -g pnpm@${PNPM_VERSION} + +WORKDIR /usr/src/app + +# Download dependencies as a separate step to take advantage of Docker's caching. +# Leverage a cache mount to /root/.local/share/pnpm/store to speed up subsequent builds. +# Leverage a bind mounts to package.json and pnpm-lock.yaml to avoid having to copy them into +# into this layer. +RUN --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ + --mount=type=cache,target=/root/.local/share/pnpm/store \ + pnpm install --prod --frozen-lockfile + +# Copy the rest of the source files into the image. +COPY . . +COPY hardhat.config.scratch.ts hardhat.config.ts + +# Expose the port that the application listens on. +EXPOSE 8545 + +# Run the application. +CMD ["pnpm", "start"]