From 70527de80f2fdb9e99314cc687b4747884a95b73 Mon Sep 17 00:00:00 2001 From: Salem Mohammed Shamakh Date: Sat, 22 Jun 2024 16:37:03 +0300 Subject: [PATCH 1/3] Create docker image --- .dockerignore | 6 ++++++ .gitignore | 2 ++ Dockerfile | 12 ++++++++++++ docker-compose.yaml | 31 +++++++++++++++++++++++++++++++ docker/bitcoin.conf | 1 + 5 files changed, 52 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100644 docker/bitcoin.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..cc03353c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +index +.gitignore +Dockerfile +docker-compose.yaml +README.md +LICENSE \ No newline at end of file diff --git a/.gitignore b/.gitignore index 83604101..93f10c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ example.db .DS_Store /client/examples/example-linux +docker/bitcoin-data +docker/indexer-data diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5f1ac47a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.22 + +WORKDIR /usr/src/app + +# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . . +RUN go build . +RUN chmod +x index +CMD ["./index", "serve", "live"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..39c46307 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,31 @@ +version: "3" +services: + bitcoind: + image: zquestz/bitcoin-cash-node + # specify additional command line arguments here + command: bitcoind + healthcheck: + test: ["CMD", "/entrypoint.sh", "bitcoin-cli", "getblockchaininfo"] + volumes: + - ./docker/bitcoin-data:/data + - ./docker/bitcoin.conf:/data/bitcoin.conf + networks: + - bitcoin + indexer: + build: . + ports: + - "26770:26770" + volumes: + - ./docker/indexer-data:/usr/src/app/db/data + depends_on: + - bitcoind + networks: + - bitcoin + environment: + - 'NODE_HOST=[bitcoind]:8333' + +networks: + bitcoin: + +volumes: + bitcoin-data: \ No newline at end of file diff --git a/docker/bitcoin.conf b/docker/bitcoin.conf new file mode 100644 index 00000000..7f54a5c7 --- /dev/null +++ b/docker/bitcoin.conf @@ -0,0 +1 @@ +txindex=1 \ No newline at end of file From 4ebef937b25caf8142f1e988a77f3f089b76e505 Mon Sep 17 00:00:00 2001 From: Salem Mohammed Shamakh Date: Mon, 24 Jun 2024 10:18:39 +0300 Subject: [PATCH 2/3] Change server host. --- Dockerfile | 1 + docker-compose.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5f1ac47a..22aa7ef5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ WORKDIR /usr/src/app COPY go.mod go.sum ./ RUN go mod download && go mod verify +EXPOSE 26770 COPY . . RUN go build . RUN chmod +x index diff --git a/docker-compose.yaml b/docker-compose.yaml index 39c46307..b3a18707 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,6 +23,7 @@ services: - bitcoin environment: - 'NODE_HOST=[bitcoind]:8333' + - 'SERVER_HOST=0.0.0.0' networks: bitcoin: From 218a156718fdd8f6eea3efc1c0d3fb30e6472bc1 Mon Sep 17 00:00:00 2001 From: Salem Mohammed Shamakh Date: Mon, 24 Jun 2024 11:48:58 +0300 Subject: [PATCH 3/3] Make port dynamic --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b3a18707..4cb0b6ed 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,7 +14,7 @@ services: indexer: build: . ports: - - "26770:26770" + - "${PORT}:26770" volumes: - ./docker/indexer-data:/usr/src/app/db/data depends_on: