Skip to content

Commit 5980d5b

Browse files
authored
chore: add Dockerfile (#33)
* chore: add Dockerfile * chore: optimize docker iamge size * chore: adding CI to push docker images * chore: test build * chore: undo test change * refactor: use commit sha instead of tags in third-party actions * refactor: use alpine in build stage * docs: add line about public docker image
1 parent 662e37a commit 5980d5b

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/*.pyc
2+
**/__pycache__

.github/workflows/docker.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: docker
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set output
11+
id: vars
12+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
13+
- name: Set up QEMU
14+
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25
17+
- name: Login to DockerHub
18+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
19+
with:
20+
username: ${{ secrets.DOCKERHUB_USERNAME }}
21+
password: ${{ secrets.DOCKERHUB_TOKEN }}
22+
- name: Build and push
23+
uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229
24+
with:
25+
push: true
26+
tags: hathornetwork/tx-mining-service:latest,hathornetwork/tx-mining-service:${{ steps.vars.outputs.tag }}
27+
platforms: linux/amd64,linux/arm64
28+
cache-from: type=gha
29+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM python:3.9-alpine as build
2+
3+
WORKDIR /code
4+
5+
# Why we need rust: https://github.com/pyca/cryptography/issues/5771
6+
RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev rust cargo
7+
8+
RUN pip --no-input --no-cache-dir install --upgrade pip wheel
9+
RUN pip --no-input --no-cache-dir install 'poetry==1.1.6'
10+
11+
COPY poetry.lock pyproject.toml /code/
12+
13+
RUN poetry config virtualenvs.create false \
14+
&& poetry install --no-dev --no-interaction --no-ansi
15+
16+
FROM python:3.9-alpine
17+
18+
COPY --from=build /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
19+
20+
COPY txstratum/ ./txstratum
21+
COPY main.py log.conf ./
22+
23+
ENTRYPOINT ["python", "-m", "main"]

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ To install dependencies, run `poetry install`.
1818

1919
python main.py https://node1.mainnet.hathor.network/
2020

21+
Or you can use the Docker image
22+
23+
docker build -t tx-mining-service .
24+
docker run -it --network="host" tx-mining-service <full-node-address:port> --address <mining-reward-address> --api-port 8080 --stratum-port 8000
25+
26+
We also have a public Docker image if you don't want to build it yourself:
27+
docker run -it --network="host" hathornetwork/tx-mining-service <full-node-address:port> --address <mining-reward-address> --api-port 8080 --stratum-port 8000
28+
2129

2230
## How to test?
2331

0 commit comments

Comments
 (0)