Skip to content

Commit 0d13bd5

Browse files
committed
Rewrite for FairCoin v3.0.0: Debian 12, new ports, multi-stage build
1 parent 35a88c1 commit 0d13bd5

3 files changed

Lines changed: 145 additions & 97 deletions

File tree

Dockerfile

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,70 @@
1-
# Usa una imagen base con Ubuntu 18.04
2-
FROM ubuntu:18.04
1+
# FairCoin Node — Docker image
2+
#
3+
# Builds faircoind v3.0.0 from source and runs it in a container.
34

4-
# Establece una variable de entorno para evitar la selección interactiva de la zona horaria
5-
ENV DEBIAN_FRONTEND=noninteractive
6-
ENV TZ=Etc/UTC
5+
FROM debian:12-slim AS builder
76

8-
# Establece un directorio de trabajo
9-
WORKDIR /app
7+
ENV DEBIAN_FRONTEND=noninteractive
108

11-
# Instala las dependencias necesarias, incluyendo una versión específica de OpenSSL
12-
RUN apt-get update && \
13-
apt-get install -y \
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
1410
build-essential \
1511
libtool \
1612
autotools-dev \
13+
autoconf \
1714
automake \
1815
pkg-config \
1916
bsdmainutils \
2017
python3 \
21-
libssl1.0-dev \
18+
libssl-dev \
2219
libevent-dev \
2320
libboost-all-dev \
21+
libdb5.3-dev \
22+
libdb5.3++-dev \
23+
libminiupnpc-dev \
24+
libzmq3-dev \
25+
ca-certificates \
2426
git \
25-
cmake \
26-
wget \
27-
gcc-7 \
28-
g++-7 && \
29-
apt-get clean && \
30-
rm -rf /var/lib/apt/lists/*
31-
32-
# Establece gcc 7 como el compilador por defecto
33-
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 50 && \
34-
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 50
35-
36-
# Descargar y compilar Berkeley DB 4.8
37-
RUN wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz && \
38-
tar -xzvf db-4.8.30.NC.tar.gz && \
39-
cd db-4.8.30.NC/build_unix && \
40-
../dist/configure --enable-cxx && \
41-
make && \
42-
make install && \
43-
cd ../.. && \
44-
rm -rf db-4.8.30.NC db-4.8.30.NC.tar.gz
45-
46-
# Establecer las variables de entorno para Berkeley DB
47-
ENV BDB_PREFIX="/usr/local/BerkeleyDB.4.8"
48-
ENV LD_LIBRARY_PATH="${BDB_PREFIX}/lib"
49-
50-
# Clona el repositorio de FairCoin
51-
RUN git clone https://github.com/FairCoinOfficial/FairCoin.git .
52-
53-
# Compila el código fuente
27+
&& rm -rf /var/lib/apt/lists/*
28+
29+
WORKDIR /build
30+
RUN git clone --depth 1 --branch main https://github.com/FairCoinOfficial/FairCoin.git .
31+
5432
RUN ./autogen.sh && \
55-
CXXFLAGS="-Wno-error" ./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" --with-ssl=openssl && \
56-
make
33+
./configure --without-gui --with-incompatible-bdb --disable-zmq && \
34+
make -j"$(nproc)" && \
35+
strip src/faircoind src/faircoin-cli src/faircoin-tx
36+
37+
# ---------- Runtime image ----------
38+
FROM debian:12-slim
39+
40+
ENV DEBIAN_FRONTEND=noninteractive
41+
42+
RUN apt-get update && apt-get install -y --no-install-recommends \
43+
libssl3 \
44+
libevent-2.1-7 \
45+
libboost-system1.74.0 \
46+
libboost-filesystem1.74.0 \
47+
libboost-thread1.74.0 \
48+
libboost-program-options1.74.0 \
49+
libboost-chrono1.74.0 \
50+
libdb5.3++ \
51+
libminiupnpc17 \
52+
gosu \
53+
&& rm -rf /var/lib/apt/lists/*
54+
55+
COPY --from=builder /build/src/faircoind /usr/local/bin/faircoind
56+
COPY --from=builder /build/src/faircoin-cli /usr/local/bin/faircoin-cli
57+
COPY --from=builder /build/src/faircoin-tx /usr/local/bin/faircoin-tx
58+
59+
RUN useradd -r -m -d /home/faircoin -s /bin/bash faircoin
60+
61+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
62+
RUN chmod +x /usr/local/bin/entrypoint.sh
63+
64+
VOLUME ["/home/faircoin/.faircoin"]
5765

58-
# Expone el puerto del nodo
59-
EXPOSE 40404
66+
EXPOSE 46372
67+
EXPOSE 46373
6068

61-
# Comando para ejecutar el nodo
62-
CMD ["./src/faircoind"]
69+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
70+
CMD ["faircoind", "-printtoconsole", "-server=1"]

README.md

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,97 @@
11
# FAIRNode
22

3-
This repository contains the Docker setup for running a FairCoin node. FairCoin is a cryptocurrency that focuses on fairness and sustainability.
3+
Docker image for running a FairCoin v3.0.0 full node.
44

5-
## Prerequisites
5+
Builds faircoind from source and runs it in a minimal Debian 12 container.
6+
7+
## Requirements
68

79
- Docker
8-
- Docker Compose (optional, for managing multi-container Docker applications)
910

10-
## Getting Started
11+
## Quick Start
1112

12-
### Clone the Repository
13+
### Build the image
1314

14-
```sh
15-
git clone https://github.com/FairCoinOfficial/FAIRNode.git
16-
cd FAIRNode
17-
```
15+
git clone https://github.com/FairCoinOfficial/FAIRNode.git
16+
cd FAIRNode
17+
docker build -t faircoin-node .
1818

19-
### Build the Docker Image
19+
### Run the node
2020

21-
```sh
22-
docker build -t faircoin-node .
23-
```
21+
docker run -d \
22+
--name faircoin-node \
23+
--restart unless-stopped \
24+
-p 46372:46372 \
25+
-v faircoin-data:/home/faircoin/.faircoin \
26+
faircoin-node
2427

25-
### Create Configuration File
28+
On first run, the entrypoint generates a faircoin.conf with a random RPC password
29+
and prints it to the logs:
2630

27-
Create a configuration file for the FairCoin node with the necessary RPC credentials and settings:
31+
docker logs faircoin-node | head
2832

29-
```sh
30-
mkdir -p ~/.faircoin
31-
echo "rpcuser=faircoinrpc" > ~/.faircoin/faircoin.conf
32-
echo "rpcpassword=your_secure_password" >> ~/.faircoin/faircoin.conf
33-
echo "server=1" >> ~/.faircoin/faircoin.conf
34-
```
33+
### Verify the node is running
3534

36-
Replace `your_secure_password` with a strong, unique password.
35+
docker exec -it faircoin-node faircoin-cli getinfo
3736

38-
### Run the Docker Container
37+
## Configuration
3938

40-
```sh
41-
docker run -d -p 53472:53472 -v ~/.faircoin:/root/.faircoin --name faircoin-node faircoin-node
42-
```
39+
### Use your own faircoin.conf
4340

44-
This command will run the FairCoin node in a Docker container with the necessary ports exposed and configuration mounted.
41+
Mount a custom config file:
4542

46-
### Verify Node is Running
43+
docker run -d \
44+
--name faircoin-node \
45+
-p 46372:46372 \
46+
-v /path/to/your/faircoin.conf:/home/faircoin/.faircoin/faircoin.conf \
47+
-v faircoin-data:/home/faircoin/.faircoin \
48+
faircoin-node
4749

48-
You can verify that the node is running by checking the container logs:
50+
### Expose the RPC port
4951

50-
```sh
51-
docker logs -f faircoin-node
52-
```
52+
By default only the P2P port (46372) is exposed. To allow RPC access from outside
53+
the container, add -p 127.0.0.1:46373:46373 (bind to localhost only for security).
5354

54-
## Configuration
55+
## Network Parameters
5556

56-
The configuration file `faircoin.conf` should be located in the `~/.faircoin` directory. You can customize this file with additional settings as needed. The default configuration includes:
57+
| | |
58+
|---|---|
59+
| Mainnet P2P port | 46372 |
60+
| Mainnet RPC port | 46373 |
61+
| Testnet P2P port | 46374 |
62+
| Testnet RPC port | 46375 |
5763

58-
```ini
59-
rpcuser=faircoinrpc
60-
rpcpassword=your_secure_password
61-
server=1
62-
```
64+
## Commands
6365

64-
## Troubleshooting
66+
# View logs
67+
docker logs -f faircoin-node
6568

66-
If you encounter any issues, please check the logs of the Docker container:
69+
# Run CLI commands
70+
docker exec -it faircoin-node faircoin-cli getinfo
71+
docker exec -it faircoin-node faircoin-cli getblockcount
6772

68-
```sh
69-
docker logs faircoin-node
70-
```
73+
# Stop / start
74+
docker stop faircoin-node
75+
docker start faircoin-node
7176

72-
## Contributing
77+
# Remove (keeps data volume)
78+
docker rm -f faircoin-node
7379

74-
Contributions are welcome! Please open an issue or submit a pull request with any improvements or fixes.
80+
## Data Persistence
7581

76-
## License
82+
Blockchain data is stored in the faircoin-data Docker volume. To back it up:
7783

78-
This project is licensed under the MIT License. See the LICENSE file for details.
84+
docker run --rm \
85+
-v faircoin-data:/data \
86+
-v $(pwd):/backup \
87+
alpine tar czf /backup/faircoin-backup.tar.gz -C /data .
7988

80-
## Acknowledgments
89+
## Links
8190

82-
- [FairCoin Official Repository](https://github.com/FairCoinOfficial/FairCoin)
83-
- Docker
91+
- [FairCoin main repository](https://github.com/FairCoinOfficial/FairCoin)
92+
- [FairCoin Explorer](https://github.com/FairCoinOfficial/Explorer)
93+
- [Website](https://fairco.in)
94+
95+
## License
96+
97+
MIT

entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CONF_DIR="/home/faircoin/.faircoin"
5+
CONF_FILE="$CONF_DIR/faircoin.conf"
6+
7+
mkdir -p "$CONF_DIR"
8+
9+
if [ ! -f "$CONF_FILE" ]; then
10+
RPC_PASS=$(head -c 32 /dev/urandom | base64 | tr -d '=+/' | head -c 32)
11+
cat > "$CONF_FILE" <<EOF
12+
rpcuser=faircoinrpc
13+
rpcpassword=${RPC_PASS}
14+
server=1
15+
listen=1
16+
daemon=0
17+
printtoconsole=1
18+
EOF
19+
echo "[entrypoint] Generated new faircoin.conf with random RPC password"
20+
echo "[entrypoint] RPC user: faircoinrpc"
21+
echo "[entrypoint] RPC pass: ${RPC_PASS}"
22+
fi
23+
24+
chown -R faircoin:faircoin "$CONF_DIR"
25+
26+
exec gosu faircoin "$@"

0 commit comments

Comments
 (0)