Skip to content

Commit

Permalink
feat: add scratch node image build step
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Feofanov committed Sep 24, 2024
1 parent 0fe4510 commit 9acc170
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/build_and_push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
with:
context: .
file: scratch.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/lidofinance/hardhat-node:${{ github.ref_name }}-scratch
17 changes: 17 additions & 0 deletions hardhat.config.scratch.ts
Original file line number Diff line number Diff line change
@@ -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;
40 changes: 40 additions & 0 deletions scratch.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 9acc170

Please sign in to comment.