Skip to content

Commit 41f3548

Browse files
committed
Add Docker setup option for collator deployment
Restructure Run the Collator section to provide both Docker and systemd setup options in tabs, consistent with other node documentation.
1 parent decf9d5 commit 41f3548

File tree

1 file changed

+139
-88
lines changed

1 file changed

+139
-88
lines changed

node-infrastructure/run-a-collator/collator.md

Lines changed: 139 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -211,72 +211,151 @@ Follow these steps to build a chainspec from the runtime:
211211
- People Chain: 1004
212212
- Coretime Chain: 1005
213213

214-
## Create User and Directory Structure
214+
## Run the Collator
215215

216-
1. Create a dedicated user with the following command:
217-
```bash
218-
sudo useradd -r -s /bin/bash polkadot
219-
```
216+
Select your preferred deployment method:
220217

221-
2. Use the following command to copy your chain spec to the directory:
222-
```bash
223-
sudo cp chain-spec.json /var/lib/polkadot-collator/
224-
```
218+
=== "Docker Setup"
225219

226-
3. Set permissions using the following command:
227-
```bash
228-
sudo chown -R polkadot:polkadot /var/lib/polkadot-collator
229-
```
220+
1. Create a directory for collator data and copy the chain spec:
221+
```bash
222+
mkdir -p collator-data
223+
cp chain-spec.json collator-data/
224+
cp /var/lib/polkadot-collator/node.key collator-data/
225+
```
230226

231-
## Create Systemd Service File
227+
2. Launch the collator using Docker:
228+
```bash
229+
docker run -d --name polkadot-collator --restart unless-stopped \
230+
-p 30333:30333 \
231+
-p 30334:30334 \
232+
-p 9944:9944 \
233+
-p 9615:9615 \
234+
-v $(pwd)/collator-data:/data \
235+
-v $(pwd)/chain-spec.json:/chain-spec.json \
236+
parity/polkadot-parachain:stable2509-2 \
237+
--collator \
238+
--chain=/chain-spec.json \
239+
--base-path=/data \
240+
--port=30333 \
241+
--rpc-port=9944 \
242+
--prometheus-port=9615 \
243+
--prometheus-external \
244+
--node-key-file=/data/node.key \
245+
--name="YourCollatorName" \
246+
--blocks-pruning=256 \
247+
--state-pruning=256 \
248+
--database=paritydb \
249+
-- \
250+
--chain=polkadot \
251+
--port=30334 \
252+
--sync=fast \
253+
--blocks-pruning=256 \
254+
--state-pruning=256 \
255+
--database=paritydb \
256+
--pool-limit=0 \
257+
--rpc-port=0
258+
```
232259

233-
1. Create a service file to hold the configuration for your collator:
234-
```bash
235-
sudo nano /etc/systemd/system/polkadot-collator.service
236-
```
260+
3. View logs to monitor sync progress:
261+
```bash
262+
docker logs -f polkadot-collator
263+
```
237264

238-
2. Open the new file and add the following configuration code:
239-
```ini title="systemd/system/polkadot-collator.service"
240-
[Unit]
241-
Description=Polkadot System Parachain Collator
242-
After=network.target
243-
244-
[Service]
245-
Type=simple
246-
User=polkadot
247-
Group=polkadot
248-
WorkingDirectory=/var/lib/polkadot-collator
249-
250-
# Block-Producing Collator Configuration
251-
ExecStart=/usr/local/bin/polkadot-parachain \
252-
--collator \
253-
--chain=/var/lib/polkadot-collator/chain-spec.json \
254-
--base-path=/var/lib/polkadot-collator \
255-
--port=30333 \
256-
--rpc-port=9944 \
257-
--prometheus-port=9615 \
258-
--node-key-file=/var/lib/polkadot-collator/node.key \
259-
--name="YourCollatorName" \
260-
--blocks-pruning=256 \
261-
--state-pruning=256 \
262-
--database=paritydb \
263-
-- \
264-
--chain=polkadot \
265-
--port=30334 \
266-
--sync=fast \
267-
--blocks-pruning=256 \
268-
--state-pruning=256 \
269-
--database=paritydb \
270-
--pool-limit=0 \
271-
--rpc-port=0
272-
273-
Restart=always
274-
RestartSec=10
275-
LimitNOFILE=65536
276-
277-
[Install]
278-
WantedBy=multi-user.target
279-
```
265+
4. Use the following commands to manage your Docker container:
266+
- Stop container:
267+
```bash
268+
docker stop polkadot-collator
269+
```
270+
- Start container:
271+
```bash
272+
docker start polkadot-collator
273+
```
274+
- Remove container:
275+
```bash
276+
docker rm polkadot-collator
277+
```
278+
279+
=== "systemd Setup"
280+
281+
1. Create a dedicated user:
282+
```bash
283+
sudo useradd -r -s /bin/bash polkadot
284+
```
285+
286+
2. Copy your chain spec to the directory:
287+
```bash
288+
sudo cp chain-spec.json /var/lib/polkadot-collator/
289+
```
290+
291+
3. Set permissions:
292+
```bash
293+
sudo chown -R polkadot:polkadot /var/lib/polkadot-collator
294+
```
295+
296+
4. Create a systemd service file:
297+
```bash
298+
sudo nano /etc/systemd/system/polkadot-collator.service
299+
```
300+
301+
5. Add the following configuration:
302+
```ini title="systemd/system/polkadot-collator.service"
303+
[Unit]
304+
Description=Polkadot System Parachain Collator
305+
After=network.target
306+
307+
[Service]
308+
Type=simple
309+
User=polkadot
310+
Group=polkadot
311+
WorkingDirectory=/var/lib/polkadot-collator
312+
313+
ExecStart=/usr/local/bin/polkadot-parachain \
314+
--collator \
315+
--chain=/var/lib/polkadot-collator/chain-spec.json \
316+
--base-path=/var/lib/polkadot-collator \
317+
--port=30333 \
318+
--rpc-port=9944 \
319+
--prometheus-port=9615 \
320+
--node-key-file=/var/lib/polkadot-collator/node.key \
321+
--name="YourCollatorName" \
322+
--blocks-pruning=256 \
323+
--state-pruning=256 \
324+
--database=paritydb \
325+
-- \
326+
--chain=polkadot \
327+
--port=30334 \
328+
--sync=fast \
329+
--blocks-pruning=256 \
330+
--state-pruning=256 \
331+
--database=paritydb \
332+
--pool-limit=0 \
333+
--rpc-port=0
334+
335+
Restart=always
336+
RestartSec=10
337+
LimitNOFILE=65536
338+
339+
[Install]
340+
WantedBy=multi-user.target
341+
```
342+
343+
6. Start the service:
344+
```bash
345+
sudo systemctl daemon-reload
346+
sudo systemctl enable polkadot-collator
347+
sudo systemctl start polkadot-collator
348+
```
349+
350+
7. Check the status:
351+
```bash
352+
sudo systemctl status polkadot-collator
353+
```
354+
355+
8. View logs:
356+
```bash
357+
sudo journalctl -u polkadot-collator -f
358+
```
280359

281360
??? note "Configuration notes"
282361

@@ -289,34 +368,6 @@ Follow these steps to build a chainspec from the runtime:
289368
- `--pool-limit=0`: Disables transaction pool on relay chain (collators don't need it)
290369
- `--rpc-port=0` (relay chain): Disables RPC on the embedded relay chain node (not needed for collators)
291370

292-
## Run the Collator
293-
294-
Follow these steps to run your collator node:
295-
296-
1. Reload systemd using the following command:
297-
```bash
298-
sudo systemctl daemon-reload
299-
```
300-
301-
2. Next, enable the service to start on boot using the command:
302-
```bash
303-
sudo systemctl enable polkadot-collator
304-
```
305-
3. Now, start the service with the following command:
306-
```bash
307-
sudo systemctl start polkadot-collator
308-
```
309-
310-
4. Finally, you can check the status of the service using the command:
311-
```bash
312-
sudo systemctl status polkadot-collator
313-
```
314-
315-
To view collator service logs, use the command:
316-
```bash
317-
sudo journalctl -u polkadot-collator -f
318-
```
319-
320371
## Complete Initial Sync
321372

322373
Your collator must sync both the relay chain and parachain before producing blocks.

0 commit comments

Comments
 (0)