diff --git a/hardhat/Dockerfile b/hardhat/Dockerfile index 418b156397..6b7a5dd112 100644 --- a/hardhat/Dockerfile +++ b/hardhat/Dockerfile @@ -1,19 +1,18 @@ -FROM node:lts-alpine +FROM node:22-alpine3.19 RUN apk add --no-cache bash -WORKDIR /usr/app +WORKDIR /usr/src/app -COPY package*.json ./ +COPY . /usr/src/app RUN npm install +RUN npm install wait-on -COPY . . +COPY $PWD/entrypoint.sh /usr/local/bin EXPOSE 8545 -COPY entrypoint.sh /usr/app/entrypoint.sh +RUN chmod +x $PWD/entrypoint.sh -RUN chmod +x /usr/app/entrypoint.sh - -ENTRYPOINT ["/usr/app/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"] \ No newline at end of file diff --git a/hardhat/entrypoint.sh b/hardhat/entrypoint.sh index 458b059dfd..2a894aac19 100644 --- a/hardhat/entrypoint.sh +++ b/hardhat/entrypoint.sh @@ -1,7 +1,14 @@ -#!/bin/bash +#!/bin/sh -# Deploy the contracts using Hardhat Ignition -npx hardhat ignition deploy /usr/app/ignition/modules/Apollo.js +# Change to the correct directory +cd /usr/src/app; -# Run the tests -npx hardhat test +# Start hardhat node as a background process +nohup npx hardhat node & + +# Wait for hardhat node to initialize and then deploy contracts +npx wait-on http://127.0.0.1:8545 && nohup npm run deploy; + +# The hardhat node process never completes +# Waiting prevents the container from pausing +wait $! \ No newline at end of file diff --git a/hardhat/ignition/modules/Apollo.js b/hardhat/ignition/modules/Apollo.js old mode 100644 new mode 100755 diff --git a/hardhat/package.json b/hardhat/package.json index ddcc29c58e..573464cd31 100644 --- a/hardhat/package.json +++ b/hardhat/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "deploy": "npx hardhat ignition deploy ./ignition/modules/Apollo.js --network localhost" }, "keywords": [], "author": "", @@ -12,6 +12,7 @@ "devDependencies": { "@nomicfoundation/hardhat-ignition-ethers": "^0.15.4", "@nomicfoundation/hardhat-toolbox": "^5.0.0", - "hardhat": "^2.22.5" + "hardhat": "^2.22.5", + "wait-on": "^7.2.0" } -} +} \ No newline at end of file