Docker image with the deployed contract

This commit is contained in:
Ruslan Gladov 2024-06-30 17:08:35 +03:00
parent babb82b4f9
commit 0545821606
4 changed files with 23 additions and 16 deletions

View file

@ -1,19 +1,18 @@
FROM node:lts-alpine FROM node:22-alpine3.19
RUN apk add --no-cache bash 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
RUN npm install wait-on
COPY . . COPY $PWD/entrypoint.sh /usr/local/bin
EXPOSE 8545 EXPOSE 8545
COPY entrypoint.sh /usr/app/entrypoint.sh RUN chmod +x $PWD/entrypoint.sh
RUN chmod +x /usr/app/entrypoint.sh ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
ENTRYPOINT ["/usr/app/entrypoint.sh"]

View file

@ -1,7 +1,14 @@
#!/bin/bash #!/bin/sh
# Deploy the contracts using Hardhat Ignition # Change to the correct directory
npx hardhat ignition deploy /usr/app/ignition/modules/Apollo.js cd /usr/src/app;
# Run the tests # Start hardhat node as a background process
npx hardhat test 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 $!

0
hardhat/ignition/modules/Apollo.js Normal file → Executable file
View file

View file

@ -3,7 +3,7 @@
"version": "1.0.0", "version": "1.0.0",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "deploy": "npx hardhat ignition deploy ./ignition/modules/Apollo.js --network localhost"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
@ -12,6 +12,7 @@
"devDependencies": { "devDependencies": {
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.4", "@nomicfoundation/hardhat-ignition-ethers": "^0.15.4",
"@nomicfoundation/hardhat-toolbox": "^5.0.0", "@nomicfoundation/hardhat-toolbox": "^5.0.0",
"hardhat": "^2.22.5" "hardhat": "^2.22.5",
"wait-on": "^7.2.0"
} }
} }