-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
192 lines (144 loc) · 6.78 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Multi-stage build setup
ARG OS_TYPE
# For Ubuntu 22.04
FROM ubuntu:22.04 as ubuntu
# Update and upgrade the system
RUN apt-get update && apt-get upgrade -y
# Download and install Dogecoin binaries
RUN curl -L https://github.com/dogecoin/dogecoin/releases/download/v1.14.7/dogecoin-1.14.7-x86_64-linux-gnu.tar.gz | tar -xz && \
mv dogecoin-1.14.7/bin/* /usr/local/bin/
# Start the Dogecoin node and run for 1 minute, then stop it
RUN dogecoind -daemon && \
sleep 60 && \
dogecoin-cli stop
# Create and configure dogecoin.conf
RUN mkdir -p /root/.dogecoin && \
echo -e "rpcuser=your\nrpcpassword=pass\nrpcallowip=127.0.0.1\nmaxconnections=50\nrpcport=22555\nserver=1\ntxindex=1\n" > /root/.dogecoin/dogecoin.conf
# Start the Dogecoin node again and wait for it to be fully synced
RUN echo "Starting Dogecoin node again..." && \
dogecoind -daemon && \
sleep 10 && \
echo "Waiting for Dogecoin node to sync..." && \
until dogecoin-cli getblockchaininfo | jq -e '.initialblockdownload == false'; do echo "Syncing..."; sleep 10800; done
# Install NVM
RUN echo "Installing NVM..." && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# Ensure NVM is sourced correctly and install npm
ENV NVM_DIR="/root/.nvm"
ENV NODE_VERSION="stable"
RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" && \
apt-get update && apt-get install -y npm
# Clone Doginals repository
RUN echo "Cloning Doginals repository..." && \
git clone https://github.com/booktoshi/doginals.git /root/doginals
# Set the working directory
WORKDIR /root/doginals
# Install npm packages
RUN echo "Installing npm packages..." && \
npm install
# Create a new wallet
RUN echo "Creating a new Doginals wallet..." && \
node . wallet new
# Copy private key from .wallet.json and import it to Dogecoin node
RUN echo "Importing private key to Dogecoin node..." && \
privateKey=$(cat .wallet.json | jq -r '.privkey') && \
dogecoin-cli importprivkey $privateKey 'wallet1' false
# Sync the wallet to the node
RUN echo "Syncing the Doginals wallet to the Dogecoin node..." && \
node . wallet sync
# Copy and install Dunes Etcher
RUN echo "Setting up Dunes Etcher..." && \
COPY doginals-main /root/doginals
WORKDIR /root/doginals/dunes-etcher
RUN npm install
# Create a new wallet for Dunes Etcher
RUN echo "Creating a new wallet for Dunes Etcher..." && \
node . wallet new
# Copy private key from .wallet.json and import it to Dogecoin node
RUN echo "Importing private key for Dunes Etcher to Dogecoin node..." && \
privateKey=$(cat .wallet.json | jq -r '.privkey') && \
dogecoin-cli importprivkey $privateKey 'wallet2' false
# Sync the wallet to the node
RUN echo "Syncing the Dunes Etcher wallet to the Dogecoin node..." && \
node . wallet sync
# Return to Doginals directory
WORKDIR /root/doginals
# Add a script to manage the state and timer
COPY manage.sh /usr/local/bin/manage.sh
RUN chmod +x /usr/local/bin/manage.sh
# Expose necessary ports
EXPOSE 22555 22556
# Start the state management script
CMD ["sh", "-c", "/usr/local/bin/manage.sh"]
# For Windows Server Core
FROM mcr.microsoft.com/windows/servercore:ltsc2022 as windows
# Set environment variables for Powershell
SHELL ["powershell", "-Command"]
# Install Chocolatey
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install necessary tools and libraries using Chocolatey
RUN choco install -y git curl nano python3 jq
# Download and install Dogecoin binaries
RUN Invoke-WebRequest -Uri https://github.com/dogecoin/dogecoin/releases/download/v1.14.7/dogecoin-1.14.7-win64.zip -OutFile dogecoin.zip ; \
Expand-Archive -Path dogecoin.zip -DestinationPath C:\dogecoin ; \
Remove-Item -Force dogecoin.zip
# Add Dogecoin binaries to PATH
RUN $env:Path += ';C:\dogecoin\dogecoin-1.14.7\bin'
# Start the Dogecoin node and run for 1 minute, then stop it
RUN Start-Process -FilePath 'dogecoind.exe' -ArgumentList '-daemon' -NoNewWindow ; \
Start-Sleep -Seconds 60 ; \
Start-Process -FilePath 'dogecoin-cli.exe' -ArgumentList 'stop' -NoNewWindow -Wait
# Create and configure dogecoin.conf
RUN New-Item -Path 'C:\Users\ContainerAdministrator\AppData\Roaming\Dogecoin' -ItemType Directory -Force ; \
Set-Content -Path 'C:\Users\ContainerAdministrator\AppData\Roaming\Dogecoin\dogecoin.conf' -Value "rpcuser=your`nrpcpassword=pass`nrpcallowip=127.0.0.1`nmaxconnections=50`nrpcport=22555`nserver=1`ntxindex=1"
# Start the Dogecoin node again and wait for it to be fully synced
RUN Start-Process -FilePath 'dogecoind.exe' -ArgumentList '-daemon' -NoNewWindow ; \
Start-Sleep -Seconds 10 ; \
echo "Waiting for Dogecoin node to sync..." ; \
while ((Invoke-WebRequest -Uri http://localhost:22555/rest/chaininfo.json).Content | ConvertFrom-Json).initialblockdownload -eq $true) { Write-Host "Syncing..."; Start-Sleep -Seconds 10800 }
# Install NVM
RUN Invoke-WebRequest -Uri https://github.com/coreybutler/nvm-windows/releases/download/1.1.9/nvm-setup.exe -OutFile nvm-setup.exe ; \
Start-Process -FilePath .\nvm-setup.exe -ArgumentList '/S' -NoNewWindow -Wait ; \
Remove-Item -Force nvm-setup.exe
# Install Node.js using NVM
RUN & "C:\Program Files\nvm\nvm.exe" install stable ; \
& "C:\Program Files\nvm\nvm.exe" use stable
# Clone Doginals repository
RUN git clone https://github.com/booktoshi/doginals.git C:\doginals
# Set the working directory
WORKDIR C:\doginals
# Install npm packages
RUN npm install
# Create a new wallet
RUN node . wallet new
# Copy private key from .wallet.json and import it to Dogecoin node
RUN $wallet = Get-Content .wallet.json | ConvertFrom-Json; \
$privateKey = $wallet.privkey; \
Start-Process -FilePath 'dogecoin-cli.exe' -ArgumentList "importprivkey $privateKey 'wallet1' false" -NoNewWindow -Wait
# Sync the wallet to the node
RUN node . wallet sync
# Copy and install Dunes Etcher
RUN COPY doginals-main\* C:\doginals
WORKDIR C:\doginals\dunes-etcher
RUN npm install
# Create a new wallet for Dunes Etcher
RUN node . wallet new
# Copy private key from .wallet.json and import it to Dogecoin node
RUN $wallet = Get-Content .wallet.json | ConvertFrom-Json; \
$privateKey = $wallet.privkey; \
Start-Process -FilePath 'dogecoin-cli.exe' -ArgumentList "importprivkey $privateKey 'wallet2' false" -NoNewWindow -Wait
# Sync the wallet to the node
RUN node . wallet sync
# Return to Doginals directory
WORKDIR C:\doginals
# Add a script to manage the state and timer
COPY manage.ps1 C:\manage.ps1
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
./manage.ps1
# Expose necessary ports
EXPOSE 22555 22556
# Start the state management script
CMD ["powershell.exe", "C:\\manage.ps1"]
# Select the appropriate stage based on OS_TYPE
FROM ${OS_TYPE}