Coder Social home page Coder Social logo

bnkamalesh / golang-dockerfile Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 5.0 13 KB

Dockerfiles for building Go application images

License: MIT License

Go 100.00%
docker dockerfile docker-image golang go go-application golang-docker-starter golang-docker

golang-dockerfile's Introduction

docker gopher

Go Dockerfile v0.1.6

Dockerfiles to build Docker images for your Go app. It makes use of Docker's multi-stage build feature to create the Go application binary, and then attach it to a minimal base image. The Go version used is 1.22, though it should work for most Go versions (not tested). You'll have to tweak the Dockerfile to COPY any static files required by the application, to be copied to the final image.

There are 4 Dockerfiles provided

  1. Debian slim based
  2. Alpine based
  3. BusyBox based
  4. Scratch (no base OS layer)

It's important that you understand Go build flags to build a functioning binary for your application. Not all apps will work with build configuration provided in the Dockerfiles.

How to build the example

$ docker build -t webgo-helloworld-alpine -f Dockerfile-alpine ./example

$ docker build -t webgo-helloworld-debian -f Dockerfile-debian ./example

$ docker build -t webgo-helloworld-busybox -f Dockerfile-busybox ./example

$ docker build -t webgo-helloworld-scratch -f Dockerfile-scratch ./example

How to run?

$ docker run -p 8080:8080 --rm -ti webgo-helloworld-alpine
$ docker run -p 8080:8080 --rm -ti webgo-helloworld-debian
$ docker run -p 8080:8080 --rm -ti webgo-helloworld-busybox
$ docker run -p 8080:8080 --rm -ti webgo-helloworld-scratch

The gopher

The gopher used here was created using Gopherize.me. The expert Docker gopher tells us how to build production ready, secure, Docker images for Go applications!

golang-dockerfile's People

Contributors

bnkamalesh avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

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.