Skip to content

Commit

Permalink
docker: Add dockerfiles for running dcrd nodes.
Browse files Browse the repository at this point in the history
This removes existing dockerfiles and adds new ones.  The removed
dockerfiles were originally used for building the testing images, but
now those images are generated by Docker Hub from the decred/dcrdocker
dockerfiles.

The new dockerfiles provide a way to build an image for running dcrd.
The main Dockerfile runs dcrd inside the same image used for building.
Dockerfile.alpine provides an alternative image that copies the built
files into an alpine based container, removing all build related content
and providing a securer and slimmer alternative.
  • Loading branch information
orthomind authored and davecgh committed Jul 7, 2018
1 parent 029fc17 commit 6c9bc1d
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 107 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
vendor
Dockerfile*
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.10.3

WORKDIR /go/src/github.com/decred/dcrd
COPY . .

RUN go get -u github.com/golang/dep/cmd/dep
RUN dep ensure
RUN go install . ./cmd/...

EXPOSE 9108

CMD dcrd
52 changes: 0 additions & 52 deletions Dockerfile-1.10

This file was deleted.

52 changes: 0 additions & 52 deletions Dockerfile-1.9

This file was deleted.

19 changes: 19 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Build image
FROM golang:1.10.3

WORKDIR /go/src/github.com/decred/dcrd
COPY . .

RUN go get -u github.com/golang/dep/cmd/dep
RUN dep ensure
RUN CGO_ENABLED=0 GOOS=linux go install . ./cmd/...

# Production image
FROM alpine:3.6

RUN apk add --no-cache ca-certificates
COPY --from=0 /go/bin/* /bin/

EXPOSE 9108

CMD dcrd
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ dcrd maintains the entire past transactional ledger of Decred and allows
about Decred please see the
[project documentation](https://docs.decred.org/#overview).

Note: To send or receive funds and join Proof-of-Stake mining, you will also need
[dcrwallet](https://github.com/decred/dcrwallet).
Note: To send or receive funds and join Proof-of-Stake mining, you will also
need [dcrwallet](https://github.com/decred/dcrwallet).

This project is currently under active development and is in a Beta state. It
is extremely stable and has been in production use since February 2016.
Expand Down Expand Up @@ -80,10 +80,59 @@ go install . ./cmd/...
```

For more information about Decred and how to set up your software please go to
our docs page at [docs.decred.org](https://docs.decred.org/getting-started/beginner-guide/).
our docs page at
[docs.decred.org](https://docs.decred.org/getting-started/beginner-guide/).

## Docker

### Running dcrd

You can run a decred node from inside a docker container. To build the image
yourself, use the following command:

```
docker build -t decred/dcrd .
```

Or you can create an alpine based image (requires Docker 17.05 or higher):

```
docker build -t decred/dcrd:alpine -f Dockerfile.alpine .
```

You can then run the image using:

```
docker run decred/dcrd
```

You may wish to use an external volume to customise your config and persist the
data in an external volume:

```
docker run --rm -v /home/user/dcrdata:/root/.dcrd/data decred/dcrd
```

For a minimal image, you can use the decred/dcrd:alpine tag. This is typically
a more secure option while also being a much smaller image.

You can run dcrctl from inside the image. For example, run an image (mounting
your data from externally) with:

```
docker run --rm -ti --name=dcrd-1 -v /home/user/.dcrd:/root/.dcrd \
decred/dcrd:alpine
```

And then run dcrctl commands against it. For example:

```
docker exec -ti dcrd-1 dcrctl getbestblock
```


### Running Tests

All tests and linters may be run in a docker container using the script
`run_tests.sh`. This script defaults to using the current supported version of
go. You can run it with the major version of Go you would like to use as the
Expand Down

0 comments on commit 6c9bc1d

Please sign in to comment.