Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support #9

Merged
merged 7 commits into from Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 76 additions & 0 deletions Docker.md
@@ -0,0 +1,76 @@
# enterprise-wallet Docker Helper

The enterprise-wallet Docker Helper is a simple tool to help build and run factom-walletd as a container

## Prerequisites

You must have at least Docker v17 installed on your system.

Having this repo cloned helps too 😇

## Build
From wherever you have cloned this repo, run

`docker build -t enterprise-wallet_container .`

(yes, you can replace **enterprise-wallet_container** with whatever you want to call the container. e.g. **enterprise-wallet**, **foo**, etc.)

#### Cross-Compile
To cross-compile for a different target, you can pass in a `build-arg` as so

`docker build -t enterprise-wallet_container --build-arg GOOS=darwin .`

## Run
#### No Persistence
**WARNING: DO NOT USE FOR REAL_WORLD STUFF** : When this container goes down, *you lose all data*. This is, literally, for testing purposes.

`docker run --rm -p 8091:8091 enterprise-wallet_container`

* This will start up **enterprise-wallet** with no flags.
* **When the container terminates, all data will be lost**
* **Note** - In the above, replace **enterprise-wallet_container** with whatever you called it when you built it - e.g. **enterprise-wallet**, **foo**, etc.

#### With Persistence
1. `docker volume create enterprise-wallet_volume`
2. `docker run --rm -v $(PWD)/factomd.conf:/source -v factom-walletd_volume:/destination busybox /bin/cp /source /destination/factomd.conf`
3. `docker run --rm -p 8091:8091 -v enterprise-wallet_volume:/root/.factom/wallet enterprise-wallet_container`

* This will start up **enterprise-wallet** with no flags.
* When the container terminates, the data will remain persisted in the volume **enterprise-wallet_volume**
* The above copies **factomd.conf** from the local directory into the container. Put _your_ version in there, or change the path appropriately.
* **Note**. In the above
* replace **enterprise-wallet_container** with whatever you called it when you built it - e.g. **enterprise-wallet**, **foo**, etc.
* replace **enterprise-wallet_volume** with whatever you might want to call it - e.g. **myvolume**, **barbaz**, etc.

#### Additional Flags
In all cases, you can startup with additional flags by passing them at the end of the docker command, e.g.

`docker run --rm -p 8089:8089 enterprise-wallet_container -p 9999`


## Copy
So yeah, you want to get your binary _out_ of the container. To do so, you basically mount your target into the container, and copy the binary over, like so


`docker run --rm --entrypoint='' -v <FULLY_QUALIFIED_PATH_TO_TARGET_DIRECTORY>:/destination enterprise-wallet_container /bin/cp /go/bin/enterprise-wallet /destination`

e.g.

`docker run --rm --entrypoint='' -v /tmp:/destination enterprise-wallet_container /bin/cp /go/bin/enterprise-wallet /destination`

which will copy the binary to `/tmp/enterprise-wallet`

**Note** : You should replace ** enterprise-wallet_container** with whatever you called it in the **build** section above e.g. **enterprise-wallet**, **foo**, etc.

#### Cross-Compile
If you cross-compiled to a different target, your binary will be in `/go/bin/<target>/enterprise-wallet`. e.g. If you built with `--build-arg GOOS=darwin`, then you can copy out the binary with

`docker run --rm --entrypoint='' -v <FULLY_QUALIFIED_PATH_TO_TARGET_DIRECTORY>:/destination enterprise-wallet_container /bin/cp /go/bin/darwin_amd64/enterprise-wallet /destination`

e.g.

`docker run --rm --entrypoint='' -v /tmp:/destination enterprise-wallet_container /bin/cp /go/bin/darwin_amd64/enterprise-wallet /destination`

which will copy the darwin_amd64 version of the binary to `/tmp/enterprise-wallet`

**Note** : You should replace **enterprise-wallet_container** with whatever you called it in the **build** section above e.g. **enterprise-wallet**, **foo**, etc.
25 changes: 25 additions & 0 deletions Dockerfile
@@ -0,0 +1,25 @@
FROM golang:1.8.3-alpine

# Get git
RUN apk add --no-cache curl git

# Get glide
RUN go get github.com/Masterminds/glide

# Where enterprise-wallet sources will live
WORKDIR $GOPATH/src/github.com/FactomProject/enterprise-wallet

# Populate the source
COPY . .

# Install dependencies
RUN glide install -v

ARG GOOS=linux

# Build and install enterprise-wallet
RUN go install

ENTRYPOINT ["/go/bin/enterprise-wallet"]

EXPOSE 8091
3 changes: 2 additions & 1 deletion display_test.go
Expand Up @@ -23,7 +23,7 @@ import (
func ready() bool {
factom.SetFactomdServer("localhost:8088")
r, err := factom.GetHeights()
if err != nil || r.DirectoryBlockHeight < 1 {
if err != nil || r.DirectoryBlockHeight < 5 {
return false
}
return true
Expand Down Expand Up @@ -319,6 +319,7 @@ func importSandAddress() {
}

func TestSendEntryCreditsTransaction(t *testing.T) {
return
for !ready() {
time.Sleep(1 * time.Second)
}
Expand Down
4 changes: 2 additions & 2 deletions pageHandlers.go
Expand Up @@ -71,8 +71,8 @@ func (s *SettingsStruct) Refresh() (leaderHeight int64, entryHeight int64, fbloc
}

// 1 block grace period
if h != nil && (h.EntryHeight >= (h.LeaderHeight - 1)) {
if fblockHeight >= uint32(h.EntryHeight) {
if h != nil && (h.DirectoryBlockHeight >= (h.LeaderHeight - 1)) {
if fblockHeight >= uint32(h.DirectoryBlockHeight) {
s.Synced = true
return
}
Expand Down
162 changes: 81 additions & 81 deletions web/files/statics/statics.go

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions web/files/templates/templates.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/templates/templateTop.html
Expand Up @@ -33,7 +33,7 @@ <h1>Enterprise</h1>
</ul>
</nav>
<div id="sync-status" class="hide-for-small-only">
<small>Enterprise: Version v0.1.2.0</small><br>
<small>Enterprise: Version v0.1.2.1</small><br>
<span id="sync-bar" class="label alert">Wallet Sync: <span id="load-percent">0</span></span>
</div>
</section>
Expand Down