Skip to content

Commit

Permalink
Merge pull request #310 from liftbridge-io/update_standalone_docker
Browse files Browse the repository at this point in the history
Update standalone Docker image to use embedded NATS server
  • Loading branch information
tylertreat authored Dec 29, 2020
2 parents 419ff53 + f5403db commit 16997ba
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 365 deletions.
6 changes: 1 addition & 5 deletions docker/dev-standalone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ FROM golang:1.14-alpine as build-base

ENV GO111MODULE on
RUN go get github.com/liftbridge-io/liftbridge@master
RUN go get github.com/nats-io/nats-server/v2

FROM alpine:latest
COPY --from=build-base /go/bin/liftbridge /usr/local/bin/liftbridge
COPY --from=build-base /go/bin/nats-server /usr/local/bin/nats-server

EXPOSE 9292 4222 8222 6222

VOLUME "/tmp/liftbridge/liftbridge-default"

COPY docker/dev-standalone/nats-server.conf nats-server.conf
COPY docker/dev-standalone/liftbridge.yaml liftbridge.yaml
COPY docker/dev-standalone/script_runner.sh script_runner.sh

RUN chmod +x script_runner.sh
CMD ./script_runner.sh
ENTRYPOINT ["liftbridge", "-c", "liftbridge.yaml"]
29 changes: 17 additions & 12 deletions docker/dev-standalone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,26 @@ We can check the logs to see if the container booted properly:

```
$ docker logs liftbridge-main
[6] 2019/08/21 11:26:09.366043 [INF] Starting nats-server version 2.0.4
[6] 2019/08/21 11:26:09.366094 [INF] Git commit [not set]
[6] 2019/08/21 11:26:09.366274 [INF] Starting http monitor on 0.0.0.0:8222
[6] 2019/08/21 11:26:09.366333 [INF] Listening for client connections on 0.0.0.0:4222
[6] 2019/08/21 11:26:09.366354 [INF] Server id is NAI5VLHK3IWC5ENOS3HARMNGZTWNRLXQCYPHTKNXXCGW5EJWR4JXCNVZ
[6] 2019/08/21 11:26:09.366358 [INF] Server is ready
[6] 2019/08/21 11:26:09.366761 [INF] Listening for route connections on 0.0.0.0:6222
time="2019-08-21 11:26:14" level=info msg="Server ID: MSQaSobS9afF1aN4E8oTIJ"
time="2019-08-21 11:26:14" level=info msg="Namespace: liftbridge-default"
time="2019-08-21 11:26:14" level=info msg="Retention Policy: [Age: 1 week, Compact: false]"
time="2019-08-21 11:26:14" level=info msg="Starting server on :9292..."
time="2019-08-21 11:26:15" level=info msg="Server became metadata leader, performing leader promotion actions"
time="2020-12-29 21:30:09" level=info msg="Liftbridge Version: v1.5.0"
time="2020-12-29 21:30:09" level=info msg="Server ID: 3qPpmKQXnP0J6xDOsIhsVb"
time="2020-12-29 21:30:09" level=info msg="Namespace: liftbridge-default"
time="2020-12-29 21:30:09" level=info msg="NATS Servers: [nats://127.0.0.1:4222]"
time="2020-12-29 21:30:09" level=info msg="Default Retention Policy: [Age: 1 week, Compact: false]"
time="2020-12-29 21:30:09" level=info msg="Default Partition Pausing: disabled"
time="2020-12-29 21:30:09" level=info msg="Starting embedded NATS server on 0.0.0.0:4222"
time="2020-12-29 21:30:09" level=info msg="nats: Starting nats-server version 2.1.9"
time="2020-12-29 21:30:09" level=info msg="nats: Git commit [not set]"
time="2020-12-29 21:30:09" level=info msg="nats: Starting http monitor on 0.0.0.0:8222"
time="2020-12-29 21:30:09" level=info msg="nats: Listening for client connections on 0.0.0.0:4222"
time="2020-12-29 21:30:09" level=info msg="nats: Server id is NDFWAP5HYPXXI52CKFACDHLEV2V3U4SBFDUKDPOHQ2LNIXYE2SUASBH6"
time="2020-12-29 21:30:09" level=info msg="nats: Server is ready"
time="2020-12-29 21:30:09" level=info msg="nats: Listening for route connections on 0.0.0.0:6222"
time="2020-12-29 21:30:09" level=info msg="Starting Liftbridge server on 0.0.0.0:9292..."
time="2020-12-29 21:30:10" level=info msg="Server became metadata leader, performing leader promotion actions"
```

If you want to advertise a docker host that is not localhost:

```
docker run -d --add-host registry:0.0.0.0 --name=liftbridge-main -p 4222:4222 -p 9292:9292 -p 8222:8222 -p 6222:6222 -eLIFTBRIDGE_HOST=registry liftbridge/standalone-dev
```
Expand Down
3 changes: 3 additions & 0 deletions docker/dev-standalone/liftbridge.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---
host: 0.0.0.0
clustering.raft.bootstrap.seed: true
nats.embedded.config: nats-server.conf
logging.nats: true
14 changes: 0 additions & 14 deletions docker/dev-standalone/script_runner.sh

This file was deleted.

6 changes: 3 additions & 3 deletions documentation/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ $ liftbridge --raft-bootstrap-peers server-2,server-3

Instead of running a binary, you can run Liftbridge using a container. There is
a [container image](https://hub.docker.com/r/liftbridge/standalone-dev)
available which runs an instance of Liftbridge and NATS inside a single Docker
container. This is meant for development and testing purposes. Use the
following Docker commands to run this container:
available which runs an instance of Liftbridge and an embedded NATS server
inside a single Docker container. This is meant for development and testing
purposes. Use the following Docker commands to run this container:

```shell
$ docker pull liftbridge/standalone-dev
Expand Down
25 changes: 0 additions & 25 deletions server/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ import (

lift "github.com/liftbridge-io/go-liftbridge/v2"
liftApi "github.com/liftbridge-io/liftbridge-api/go"
natsdTest "github.com/nats-io/nats-server/v2/test"
"github.com/stretchr/testify/require"
)

// Ensure activity stream creation event occurs.
func TestActivityStreamCreateStream(t *testing.T) {
defer cleanupStorage(t)

// Use a central NATS server.
ns := natsdTest.RunDefaultServer()
defer ns.Shutdown()

// Configure server.
s1Config := getTestConfig("a", true, 5050)
s1Config.ActivityStream.Enabled = true
Expand Down Expand Up @@ -64,10 +59,6 @@ func TestActivityStreamCreateStream(t *testing.T) {
func TestActivityStreamDeleteStream(t *testing.T) {
defer cleanupStorage(t)

// Use a central NATS server.
ns := natsdTest.RunDefaultServer()
defer ns.Shutdown()

// Configure server.
s1Config := getTestConfig("a", true, 5050)
s1Config.ActivityStream.Enabled = true
Expand Down Expand Up @@ -117,10 +108,6 @@ func TestActivityStreamDeleteStream(t *testing.T) {
func TestActivityStreamPauseStream(t *testing.T) {
defer cleanupStorage(t)

// Use a central NATS server.
ns := natsdTest.RunDefaultServer()
defer ns.Shutdown()

// Configure server.
s1Config := getTestConfig("a", true, 5050)
s1Config.ActivityStream.Enabled = true
Expand Down Expand Up @@ -172,10 +159,6 @@ func TestActivityStreamPauseStream(t *testing.T) {
func TestActivityStreamResumeStream(t *testing.T) {
defer cleanupStorage(t)

// Use a central NATS server.
ns := natsdTest.RunDefaultServer()
defer ns.Shutdown()

// Configure server.
s1Config := getTestConfig("a", true, 5050)
s1Config.ActivityStream.Enabled = true
Expand Down Expand Up @@ -230,10 +213,6 @@ func TestActivityStreamResumeStream(t *testing.T) {
func TestActivityStreamSetStreamReadonly(t *testing.T) {
defer cleanupStorage(t)

// Use a central NATS server.
ns := natsdTest.RunDefaultServer()
defer ns.Shutdown()

// Configure server.
s1Config := getTestConfig("a", true, 5050)
s1Config.ActivityStream.Enabled = true
Expand Down Expand Up @@ -285,10 +264,6 @@ func TestActivityStreamSetStreamReadonly(t *testing.T) {
func TestActivityStreamSetStreamReadwrite(t *testing.T) {
defer cleanupStorage(t)

// Use a central NATS server.
ns := natsdTest.RunDefaultServer()
defer ns.Shutdown()

// Configure server.
s1Config := getTestConfig("a", true, 5050)
s1Config.ActivityStream.Enabled = true
Expand Down
Loading

0 comments on commit 16997ba

Please sign in to comment.