Giter Site home page Giter Site logo

go-demo's Introduction

scripts/setup.sh

docker-compose \
    -f docker-compose-test.yml \
    run --rm unit

docker build -t vfarcic/go-demo .

docker tag vfarcic/go-demo vfarcic/go-demo:1.0

docker tag vfarcic/go-demo vfarcic/go-demo:1.1

docker push vfarcic/go-demo

docker push vfarcic/go-demo:1.0

docker push vfarcic/go-demo:1.1

docker-compose up -d db app

go-demo's People

Contributors

albers avatar mingsterism avatar vfarcic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-demo's Issues

go-demo can't connect to mongo db

Hi Viktor,
I am trying to setup my docker swarm based from the examples in The DevOps 2.1 Toolkit: Docker Swarm (excellent by the way!)

However when I create the go-demo service. the service failed:

[root@node1 ~]# docker logs 7148c0412577
panic: no reachable servers

goroutine 1 [running]:
panic(0x7b6480, 0xc8200c9be0)
/usr/local/go/src/runtime/panic.go:481 +0x3e6
main.setupDb()
/usr/src/myapp/main.go:43 +0xc5
main.main()
/usr/src/myapp/main.go:30 +0x14
[root@node1 ~]# docker ps -a

Here's my setup

[root@doc-machine ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
30b0diuj42e1xi8nb1f6dcrum node2 Ready Active
8birurzpi03fbsmobk72keui7 manager2 Ready Active Reachable
9cr88tkl4xtyosdee9mmwly6h * manager1 Ready Active Leader
c53wp9ks0qcplme644v4m0zls node3 Ready Active
dp2n67k8cbtayqh8q3p1r9fjg node1 Ready Active

[root@node1 ~]# docker network ls
NETWORK ID NAME DRIVER SCOPE
8bd68935c031 bridge bridge local
bb69ba346363 docker_gwbridge bridge local
3ekgvwum4aop go-demo overlay swarm
131cd854ca31 host host local
9vyjyb8eci2q ingress overlay swarm
ae35a08628f6 none null local

ID NAME REPLICAS IMAGE COMMAND
2ay9q7t57zjm proxy 1/1 vfarcic/docker-flow-proxy
7wpms6fjw3lo go-demo-db 1/1 mongo:3.2.10
85dzs6wx7h2y go-demo 0/1 vfarcic/go-demo:1.0
f2b6u7eqnr9o util global alpine sleep 1000000000
[root@doc-machine ~]#

I can't figure out what is causing the issue

Thank's

Regards

Robert

unit service not working

❯ docker-compose -f docker-compose-test-local.yml  run --rm unit
WARN[0000] The "HOST_IP" variable is not set. Defaulting to a blank string.
Fetching https://gopkg.in/mgo.v2?go-get=1
Parsing meta tags from https://gopkg.in/mgo.v2?go-get=1 (status code 200)
get "gopkg.in/mgo.v2": found meta tag get.metaImport{Prefix:"gopkg.in/mgo.v2", VCS:"git", RepoRoot:"https://gopkg.in/mgo.v2"} at https://gopkg.in/mgo.v2?go-get=1
go: finding gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
go: gopkg.in/[email protected]: git fetch -f https://gopkg.in/mgo.v2 refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/71c6fba555fd7b185c93dcad3ed507d63007e825cf56a4a329b0e102990a7036: exit status 128:
        fatal: unable to access 'https://gopkg.in/mgo.v2/': server certificate verification failed. CAfile: none CRLfile: none
go: error loading module requirements

I don't know about Go well yet, but the package seems deprecated.

go get: -t flag is a no-op when using modules

10:19 $ docker-compose -f docker-compose-test-local.yml run --rm staging
WARNING: The HOST_IP variable is not set. Defaulting to a blank string.
go get: -t flag is a no-op when using modules
=== RUN   TestIntegrationTestSuite
=== RUN   TestIntegrationTestSuite/Test_Hello_ReturnsStatus200
=== RUN   TestIntegrationTestSuite/Test_Person_ReturnsStatus200
--- PASS: TestIntegrationTestSuite (0.01s)
    --- PASS: TestIntegrationTestSuite/Test_Hello_ReturnsStatus200 (0.00s)
    --- PASS: TestIntegrationTestSuite/Test_Person_ReturnsStatus200 (0.00s)
=== RUN   TestMainSuite
=== RUN   TestMainSuite/Test_HelloServer_Waits_WhenDelayIsPresent
=== RUN   TestMainSuite/Test_HelloServer_WritesHelloWorld
=== RUN   TestMainSuite/Test_HelloServer_WritesNokEventually
=== RUN   TestMainSuite/Test_HelloServer_WritesOk
=== RUN   TestMainSuite/Test_PersonServer_InvokesUpsertId_WhenPutPerson
=== RUN   TestMainSuite/Test_PersonServer_Panics_WhenFindReturnsError
=== RUN   TestMainSuite/Test_PersonServer_Panics_WhenUpsertIdReturnsError
=== RUN   TestMainSuite/Test_PersonServer_WritesPeople
=== RUN   TestMainSuite/Test_RunServer_InvokesListenAndServe
=== RUN   TestMainSuite/Test_SetupMetrics_InitializesHistogram
--- PASS: TestMainSuite (0.01s)
    --- PASS: TestMainSuite/Test_HelloServer_Waits_WhenDelayIsPresent (0.00s)
    --- PASS: TestMainSuite/Test_HelloServer_WritesHelloWorld (0.00s)
    --- PASS: TestMainSuite/Test_HelloServer_WritesNokEventually (0.00s)
    --- PASS: TestMainSuite/Test_HelloServer_WritesOk (0.00s)
    --- PASS: TestMainSuite/Test_PersonServer_InvokesUpsertId_WhenPutPerson (0.00s)
    --- PASS: TestMainSuite/Test_PersonServer_Panics_WhenFindReturnsError (0.00s)
    --- PASS: TestMainSuite/Test_PersonServer_Panics_WhenUpsertIdReturnsError (0.00s)
    --- PASS: TestMainSuite/Test_PersonServer_WritesPeople (0.00s)
    --- PASS: TestMainSuite/Test_RunServer_InvokesListenAndServe (0.00s)
    --- PASS: TestMainSuite/Test_SetupMetrics_InitializesHistogram (0.00s)
PASS
ok  	go-demo-6	0.030s

go test fails

On Ubuntu:

max@max-x1:~/work/go-demo$ docker-compose -f docker-compose-test-local.yml run --rm unit
WARNING: The HOST_IP variable is not set. Defaulting to a blank string.
src/github.com/stretchr/testify/assert/assertions.go:17:2: cannot find package "github.com/davecgh/go-spew/spew" in any of:
	/usr/local/go/src/github.com/davecgh/go-spew/spew (from $GOROOT)
	/go/src/github.com/davecgh/go-spew/spew (from $GOPATH)
src/github.com/stretchr/testify/assert/assertions.go:18:2: cannot find package "github.com/pmezard/go-difflib/difflib" in any of:
	/usr/local/go/src/github.com/pmezard/go-difflib/difflib (from $GOROOT)
	/go/src/github.com/pmezard/go-difflib/difflib (from $GOPATH)
src/github.com/stretchr/testify/mock/mock.go:14:2: cannot find package "github.com/stretchr/objx" in any of:
	/usr/local/go/src/github.com/stretchr/objx (from $GOROOT)
	/go/src/github.com/stretchr/objx (from $GOPATH)
package ./src/gopkg.in/mgo.v2
	imports gopkg.in/mgo.v2/internal/scram: use of internal package not allowed
package ./src/gopkg.in/mgo.v2/bson
	imports gopkg.in/mgo.v2/internal/json: use of internal package not allowed
src/gopkg.in/mgo.v2/dbtest/dbserver.go:13:2: cannot find package "gopkg.in/tomb.v2" in any of:
	/usr/local/go/src/gopkg.in/tomb.v2 (from $GOROOT)
	/go/src/gopkg.in/tomb.v2 (from $GOPATH)



max@max-x1:~/work/go-demo$ docker-machine ls 
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
go-demo   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.13.1   



max@max-x1:~/work/go-demo$ docker-machine --version
docker-machine version 0.9.0, build 15fd4c7
max@max-x1:~/work/go-demo$ docker-compose --version
docker-compose version 1.10.0, build 4bd6f1a
max@max-x1:~/work/go-demo$ docker --version
Docker version 1.13.1, build 092cba3
max@max-x1:~/work/go-demo$ 

Any ideas what I am doing wrong?

'docker-compose-test-local.yml' unit doesn't work on windows

this is my first issue in my life.
and i'm not native english.
sorry.

i installed docker toolbox on windows.
and made go-demo docker machine virtual driver.
i get sources from this git repository (thank you. that is very nice all things)
to my path ( e:/project/go-demo/... )

so, i did test by command ( docker-compose -f docker-compose-test-lcoal.yml run -d --rm unit )

and i typeed to get log info. but received massage about ' can't compile on path /usr/bin/myapp/. because not found source ' maybe. but that meaning.

so i did those commands in my linux Vagrant server only using 'docker-compose and docker' , but it works well.

i wonder why it didn't work on windows ( Docker quick terminal )
i love your all books. bye

go-demo can't connect to mongo db Vol2

Hi Viktor!
Actually I am going thru the DevOps2.1 book and I really enjoy it:)
I started to play with the exercises but I stuck with the go-demo with mongo DB.
I have a very similar issue as rlaflamme had, except in my case not the firewall is the problem.

If I manually create a container I can write a python code which can interact with the go-demo-db. So the network connection looks fine.
But still the go-demo cannot connect to the DB. Env variables are fine, names ok as well.

This is what I can see in the logs. I hope you can shed some light what I missed here:)
Thank you!

docker@dockerVM1:~$ docker service ps c1lncxif6wre
ID            NAME           IMAGE                NODE       DESIRED STATE  CURRENT STATE           ERROR                      PORTS
wjsjqoqqawwd  go-demo.1      vfarcic/go-demo:1.0  dockerVM1  Running        Starting 3 seconds ago
pbrutjvn0tst   \_ go-demo.1  vfarcic/go-demo:1.0  dockerVM1  Shutdown       Failed 8 seconds ago    "task: non-zero exit (2)"
docker@dockerVM1:~$

docker@dockerVM1:~$ docker logs cc0765a6f497
panic: no reachable servers

goroutine 1 [running]:
panic(0x7b6480, 0xc82005b510)
        /usr/local/go/src/runtime/panic.go:481 +0x3e6
main.setupDb()
        /usr/src/myapp/main.go:43 +0xc5
main.main()
        /usr/src/myapp/main.go:30 +0x14

docker@dockerVM1:~$ docker service inspect go-demo --pretty

ID:             c1lncxif6wreegelqlaeytn2e
Name:           go-demo
Service Mode:   Replicated
 Replicas:      1
Placement:
UpdateConfig:
 Parallelism:   1
 On failure:    pause
 Max failure ratio: 0
ContainerSpec:
 Image:         vfarcic/go-demo:1.0@sha256:a578350216c5939ee518c9f57d040cf8a54ebc5d1a85292bfdf505394b040e5b
 Env:           DB=go-demo-db
Resources:
Networks: go-demo
Endpoint Mode:  vip
docker@dockerVM1:~$ docker service inspect go-demo-db --pretty

ID:             xkfr7ngsbgu44pqxmoxf1ab3c
Name:           go-demo-db
Service Mode:   Replicated
 Replicas:      1
Placement:
UpdateConfig:
 Parallelism:   1
 On failure:    pause
 Max failure ratio: 0
ContainerSpec:
 Image:         mongo:3.2.10@sha256:532a19da83ee0e4e2a2ec6bc4212fc4af26357c040675d5c2629a4e4c4563cef
Resources:
Networks: go-demo
Endpoint Mode:  vip
docker@dockerVM1:~$

Jenkinsfile with declarative syntax doesn't connect to docker-engine at $DOCKER_HOST

Hello Viktor,

in line 29 of 'Jenkinsfile' during a Jenkins run I get the error:

  • DOCKER_HOST=tcp://192.168.99.100:2375 docker service update --image localhost:5000/myservice:2.12 myservice
    Cannot connect to the Docker daemon at tcp://192.168.99.100:2375. Is the docker daemon running?

Trying this command inside the jenkins-agent container braught me to a working solution:
Also set DOCKER_MACHINE_NAME and DOCKER_CERT_PATH.

Thanx for your terrific work!

bye
Stephan

failed Test_Hello_ReturnsStatus200

This error is not isolated at Mac OS X system, but even in Debian Linux.

Version
[Mac OS X]
pirate$ docker --version
Docker version 17.03.1-ce, build c6d412e

pirate$ docker-machine --version
docker-machine version 0.10.0, build 76ed2a6

pirate$ docker-compose --version
docker-compose version 1.11.2, build dfed245

pirate$ uname -a
Darwin pirate-MBP 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64

[Debian Linux]
pirate$ docker --version
Docker version 17.03.1-ce, build c6d412e

pirate$ docker-machine --version
docker-machine version 0.10.0 build 76ead2a6

pirate$ uname -a
Linux debian 3.16.0-4 amd64 #1 SMP Debian 3.16.39+deb8u2 (2017-03-07) x86_64 GNU/Linux

Steps to reproduce the issue:
[you can try even within a docker-machine node with virtualbox or pwd driver, the result is the same  ]
pirate$ docker-compose -f docker-compose-test-local.yml  up -d staging-dep
Creating godemo_db_1
Creating godemo_staging-dep_1

pirate$ docker-compose  -f docker-compose-test-local.yml ps
WARNING: The HOST_IP variable is not set. Defaulting to a blank string.
        Name                  Command          State           Ports          
-----------------------------------------------------------------------------
godemo_db_1            /entrypoint.sh mongod   Up      27017/tcp              
godemo_staging-dep_1   go-demo                 Up      0.0.0.0:8080->8080/tcp 

pirate$ docker-compose  -f docker-compose-test-local.yml run --rm staging
WARNING: The HOST_IP variable is not set. Defaulting to a blank string.
Pulling staging (golang:1.6)...
1.6: Pulling from library/golang
....
=== RUN   TestIntegrationTestSuite
=== RUN   Test_Hello_ReturnsStatus200
--- FAIL: Test_Hello_ReturnsStatus200 (20.00s)
        Error Trace:    integration_test.go:48
	Error:      	Received unexpected error:
	            	Get http://staging-dep:8080/demo/hello: dial tcp: lookup staging-dep on 10.0.2.3:53: read udp 10.0.2.15:52485->10.0.2.3:53: i/o timeout
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x486092]

goroutine 6 [running]:
panic(0x8ab9e0, 0xc82000e0b0)
	/usr/local/go/src/runtime/panic.go:481 +0x3e6
testing.tRunner.func1(0xc82007e120)
	/usr/local/go/src/testing/testing.go:467 +0x192
panic(0x8ab9e0, 0xc82000e0b0)
	/usr/local/go/src/runtime/panic.go:443 +0x4e9
_/usr/src/myapp.IntegrationTestSuite.Test_Hello_ReturnsStatus200(0xc8201ee560, 0xc8201ee570, 0xc82007e120, 0xc82000a068, 0x10)
	/usr/src/myapp/integration_test.go:49 +0x232
_/usr/src/myapp.(*IntegrationTestSuite).Test_Hello_ReturnsStatus200(0xc8200514d0)
	<autogenerated>:77 +0x98
reflect.Value.call(0x7e5860, 0x93dad8, 0x13, 0x945710, 0x4, 0xc820043f08, 0x1, 0x1, 0x0, 0x0, ...)
	/usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0x7e5860, 0x93dad8, 0x13, 0xc820043f08, 0x1, 0x1, 0x0, 0x0, 0x0)
	/usr/local/go/src/reflect/value.go:303 +0xb1
github.com/stretchr/testify/suite.Run.func2(0xc82007e120)
	/go/src/github.com/stretchr/testify/suite/suite.go:101 +0x3c9
testing.tRunner(0xc82007e120, 0xc8201f0660)
	/usr/local/go/src/testing/testing.go:473 +0x98
created by testing.RunTests
	/usr/local/go/src/testing/testing.go:582 +0x892
exit status 2
FAIL	_/usr/src/myapp	20.013s

Error running examples in CI chapter

Hi Viktor, thanks for wonderful book I enjoy reading it

Please help with this error in Windows10/Virtualbox doesn't allow me to continue with the examples :(

The command I issued:
docker-compose -f docker-compose-test-local.yml run --rm unit

Thanks in advance!

tmp/go/src/github.com/stretchr/testify/assert/assertions.go:17:2: cannot find package "github.com/davecgh/go-spew/spew" in any of:
        /usr/local/go/src/github.com/davecgh/go-spew/spew (from $GOROOT)
        /go/src/github.com/davecgh/go-spew/spew (from $GOPATH)
tmp/go/src/github.com/stretchr/testify/assert/assertions.go:18:2: cannot find package "github.com/pmezard/go-difflib/difflib" in any of:
        /usr/local/go/src/github.com/pmezard/go-difflib/difflib (from $GOROOT)
        /go/src/github.com/pmezard/go-difflib/difflib (from $GOPATH)
tmp/go/src/github.com/stretchr/testify/mock/mock.go:14:2: cannot find package "github.com/stretchr/objx" in any of:
        /usr/local/go/src/github.com/stretchr/objx (from $GOROOT)
        /go/src/github.com/stretchr/objx (from $GOPATH)
package ./tmp/go/src/gopkg.in/mgo.v2
        imports gopkg.in/mgo.v2/internal/scram: use of internal package not allowed
package ./tmp/go/src/gopkg.in/mgo.v2/bson
        imports gopkg.in/mgo.v2/internal/json: use of internal package not allowed
tmp/go/src/gopkg.in/mgo.v2/dbtest/dbserver.go:13:2: cannot find package "gopkg.in/tomb.v2" in any of:
        /usr/local/go/src/gopkg.in/tomb.v2 (from $GOROOT)
        /go/src/gopkg.in/tomb.v2 (from $GOPATH)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.