Skip to content

Commit

Permalink
dockerfile: update and add docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
boymanjor committed Apr 16, 2020
1 parent 2d5ab27 commit cb182f4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 16 deletions.
26 changes: 10 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
FROM node:alpine AS base
RUN mkdir -p /code
WORKDIR /code
CMD "hsd"
FROM node:10-alpine AS base
WORKDIR /opt/hsd
RUN apk add --no-cache bash unbound-dev gmp-dev
COPY package.json /opt/hsd

RUN apk upgrade --no-cache && \
apk add --no-cache bash unbound-dev gmp-dev

COPY package.json \
#package-lock.json \
/code/

# Install build dependencies and compile
# Install build dependencies and compile.
FROM base AS build
RUN apk add --no-cache g++ gcc make python2
RUN npm install --production

FROM base
ENV PATH="${PATH}:/code/bin:/code/node_modules/.bin"
COPY --from=build /code/node_modules /code/node_modules/
COPY bin /code/bin/
COPY lib /code/lib/
ENV PATH="${PATH}:/opt/hsd/bin:/opt/hsd/node_modules/.bin"
COPY --from=build /opt/hsd/node_modules /opt/hsd/node_modules/
COPY bin /opt/hsd/bin/
COPY lib /opt/hsd/lib/
ENTRYPOINT ["hsd"]
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,50 @@ Note that `node-gyp` must be installed. See the
[node-gyp](https://github.com/nodejs/node-gyp) documentation for more
information.

### Docker
#### Building an image

To build a Docker image with the name `hsd:<version>-<commit>`, run:

```bash
$ VERSION=$(cat package.json | grep version | sed 's/.*"\([0-9]*\.[0-9]*\.[0-9]*\)".*/\1/')
$ COMMIT=$(git rev-parse --short HEAD)
$ docker build -t hsd:$VERSION-$COMMIT .
```

#### Running a container

To start a container named `hsd` on a `regtest` network with an exposed
node API server, run:

```bash
$ docker run --name hsd -p 14037:14037 hsd:$VERSION-$COMMIT \
--network regtest \
--http-host 0.0.0.0 \
--api-key=foo
```

To test connectivity, curl the info endpoint:
```bash
$ curl http://x:foo@localhost:14037/
```

>Note: by default, none of the container's ports are exposed. Depending
on the network used for your node, you will need to expose the correct ports
for the node's various services (node http api, wallet http api, recursive
name server, authoritative name server, p2p protocol, encrypted p2p protocol).
The default ports can be found [here](./lib/protocol/networks.js). The DNS
servers must also expose a UDP port. The syntax is different from TCP and can
be found [here](https://docs.docker.com/config/containers/container-networking/#published-ports).

#### Stopping a container

To stop a container named `hsd`, run:

```bash
$ docker stop hsd
```

### npm

It is not recommended to install `hsd` from npm's repositories
Expand Down

0 comments on commit cb182f4

Please sign in to comment.