Coder Social home page Coder Social logo

shahidhk / go-docker Goto Github PK

View Code? Open in Web Editor NEW
90.0 6.0 14.0 11 KB

Sample code and dockerfiles accompanying the blog post The Ultimate Guide to Writing Dockerfiles for Go Web-apps

Home Page: https://hasura.io/blog/the-ultimate-guide-to-writing-dockerfiles-for-go-web-apps-336efad7012c/

License: MIT License

Go 100.00%
golang go docker live-reload gin glide upx multistage alpine scratch

go-docker's Introduction

go-docker

A simple web app written in Go, with dockerfiles for development and production.

Build and run using any dockerfile:

$ docker build -f [dockerfile] -t go-docker .
$ docker run --rm -it -p 8080:8080 go-docker

See branch glide for glide based workflow instead of dep.

go-docker's People

Contributors

ben-st avatar shahidhk 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-docker's Issues

bad url in the github header

The link to the blog post is broken.

The good link is https://blog.hasura.io/the-ultimate-guide-to-writing-dockerfiles-for-go-web-apps-336efad7012c/.

使用1-simple.dockerfile ,创建镜像,运行镜像时,找不到jar

1负责文件
2[root@localhost go-docker]# docker build -t go-docker-dev .
Sending build context to Docker daemon 2.731 MB
Step 1/4 : FROM golang:1.8.5-jessie
---> ba52c9ef0f5c
Step 2/4 : WORKDIR /go/src/app
---> effc79fb9241
Removing intermediate container 15b6cd759a61
Step 3/4 : ADD src src
---> ca68dbcf11e8
Removing intermediate container 440c214ff105
Step 4/4 : CMD go run src/main.go
---> Running in 29ac9d1444eb
---> 95251f8b50f2
Removing intermediate container 29ac9d1444eb
Successfully built 95251f8b50f2
[root@localhost go-docker]# docker run --rm -it -p 8090:8080 go-docker-dev
src/main.go:8:2: cannot find package "github.com/sirupsen/logrus" in any of:
/usr/local/go/src/github.com/sirupsen/logrus (from $GOROOT)
/go/src/github.com/sirupsen/logrus (from $GOPATH)
[root@localhost go-docker]#
3、报错。

What do you do when your project depends on your own source code?

This file ALMOST takes me there:

But if src/main.go is instead cmd/main.go:

import "github.com/shahidhk/go-docker/pkg/printfoo"
func main() {
  printfoo.Print()
}

And the contents of pkg/printfoo.go are:

package printfoo
func Print() {
  fmt.Println("foo")
}

Then dep will pull into Gopkg.toml whatever is checked in to GitHub with --vendor-only for pkg/printfoo and not what is local. Especially if this Dockerfile lives in cmd/ which is what you would want to do if you were making a number of different binaries for command line programs but that all use a common library.

What do you do in these cases other than continuously checking your code into GitHub to ensure the dependency pulls the latest stuff from pkg/...? The Dockerfile is not permitted to do a COPY ../pkg ./ so I am not sure how to do this without placing the Dockerfile in the root of the project. Thank you for your help in advance!

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.