Skip to content

Commit 97ffbd5

Browse files
committed
docker環境構築修正
1 parent f189aa5 commit 97ffbd5

7 files changed

+361
-24
lines changed

.env.example

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
INFRA_API_KEY=https://rinkeby.infura.io/v3/
2-
PRIVATE_KEY=0xabc123
3-
MINTER_ADDRESS=0x...
4-
TO_ADDRESS=0x...
1+
UID=1001
2+
GID=1001
3+
PRIVATE_KEY=
4+
MINTER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
5+
MINTER_ADMIN_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
6+
PAUSER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
7+
BLOCKLISTER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
8+
RESCUER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
9+
OWNER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
10+
TO_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
511
MINT_AMOUNT=1000000
6-
12+
TOKEN_NAME=TESTJPYC
13+
TOKEN_SYMBOL=TJPYC
14+
TOKEN_CURRENCY=TJPYC
15+
TOKEN_DECIMALS=18
716

compose.yaml

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
services:
2-
32
app:
43
build:
54
context: .
65
dockerfile: ./local.Dockerfile
6+
args:
7+
UID: ${UID:-1001}
8+
GID: ${GID:-1001}
79
tty: true
8-
user: ${UID}:${GID} # ホストと同じユーザーで実行
10+
user: "${UID:-1001}:${GID:-1001}"
911
ports:
1012
- 8545:8545 # contract RPC
1113
volumes:
12-
- .:/root/project
13-
14+
- .:/workspace
15+
- vscode-server:/home/appuser/.vscode-server
16+
environment:
17+
- HOME=/home/appuser
18+
- SHELL=/bin/bash
19+
working_dir: /workspace
20+
21+
volumes:
22+
vscode-server:

hardhat.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ const config: HardhatUserConfig = {
3939
mnemonic: "test test test test test test test test test test test junk",
4040
},
4141
},
42+
43+
mainnet: {
44+
url: `https://eth-mainnet.g.alchemy.com/v2/Bee-BKs-NFFdtrZUEcjMoPQwqI08J0NS`,
45+
chainId: 1,
46+
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
47+
},
4248
},
4349
};
4450

local.Dockerfile

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
FROM node:20.11.1-bookworm-slim
22

3+
ARG UID=1001
4+
ARG GID=1001
5+
36
RUN apt update && apt upgrade -y
47
RUN apt install -y \
58
curl \
69
wget \
7-
git
10+
git \
11+
sudo
812

913
# bashで日本語が表示されるようにする
1014
RUN apt install -y locales
1115
RUN localedef -f UTF-8 -i ja_JP ja_JP
12-
RUN echo "export LANG=ja_JP.UTF-8" >> ~/.bashrc
16+
RUN echo "export LANG=ja_JP.UTF-8" >> /etc/bash.bashrc
17+
18+
# 非rootユーザーを作成
19+
RUN groupadd -g $GID appuser || groupmod -g $GID $(getent group $GID | cut -d: -f1)
20+
RUN useradd -m -u $UID -g $GID -s /bin/bash appuser || usermod -u $UID -g $GID appuser
21+
22+
USER appuser
23+
WORKDIR /workspace
1324
# pnpm
1425
RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
1526
# foundry
1627
RUN curl -L https://foundry.paradigm.xyz | bash
17-
ENV PATH=/root/.foundry/bin:$PATH
18-
RUN foundryup
28+
ENV PATH=/home/appuser/.foundry/bin:$PATH
29+
RUN foundryup
30+
31+
# 必要なディレクトリを作成し、権限を設定
32+
RUN mkdir -p /home/appuser/.vscode-server && \
33+
chown -R $UID:$GID /home/appuser && \
34+
chmod -R 755 /home/appuser
35+
36+
RUN cat /etc/passwd

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,25 @@
1111
"license": "ISC",
1212
"dependencies": {
1313
"@openzeppelin/contracts": "^5.0.2",
14-
"chai": "^5.1.1",
1514
"dotenv": "^16.4.5",
15+
"ethers": "^6.1.0",
1616
"hardhat-contract-sizer": "^2.10.0",
17-
"solidity-coverage": "^0.8.13",
18-
"viem": "^2.21.6"
17+
"solidity-coverage": "^0.8.13"
1918
},
2019
"devDependencies": {
21-
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
20+
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
21+
"@nomicfoundation/hardhat-ethers": "^3.0.0",
2222
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
2323
"@nomicfoundation/hardhat-viem": "^2.0.4",
2424
"@nomiclabs/hardhat-truffle5": "^2.0.7",
2525
"@nomiclabs/hardhat-web3": "^2.0.0",
26-
"@openzeppelin/hardhat-upgrades": "^3.2.1",
26+
"@openzeppelin/hardhat-upgrades": "^3.3.0",
2727
"@types/mocha": "^10.0.8",
2828
"@types/node": "^22.5.4",
29+
"chai": "^4.5.0",
2930
"hardhat": "^2.22.10",
3031
"ts-node": "^10.9.2",
32+
"viem": "^2.21.8",
3133
"web3": "^1.10.4"
3234
}
33-
}
34-
35+
}

script/Deployscript.ts

-4
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ async function mintTokens(jpyc: any, minterAddress: string, toAddress: string, a
8585
account: minterAddress,
8686
});
8787

88-
89-
90-
9188
console.log("token minted");
92-
9389
console.log("mint address:", toAddress);
9490
console.log("tx:", tx);
9591
console.log("mint amount:", amount.toString());

0 commit comments

Comments
 (0)