Coder Social home page Coder Social logo

alpine-golang's Introduction

Alpine (golang)

This Docker image is used to build Go service projects on the LUSHDigital infrastructure. It is not supposed to be used to run images in production, but rather to serve as a an intermediary image in staged docker builds to produce artefacts.

Setting up your project Dockerfile

Since we don't need to have the entire Go toolchain in our production images, we can take the build artefacts from the first build stage and put them in another.

FROM lushdigital/alpine-golang:latest
FROM alpine:latest
# Copy from the first stage of the build process
COPY --from=0 /repo/build build
RUN ["build/service"]

Using build variables in your Go code

The image will build your projects with -ldflags setting two variables in your main package called tag containing the very latest version tag of your tree and ref containing the current git commit hash.

package main

var (
    tag  string
    ref string
)

func main() {
    ...
}

Using build variables in the LUSHDigital/core package

This package will also use the build flags to interpolate the commit hash and latest version tag straight into the LUSHDigital/core package.

package main

import (
    "github.com/LUSHDigital/core"
)

func main() {
    // The service struct will now automatically contain the commit hash and latest version tag derived from the build flags.
    service := core.NewService("example", "service")
    ...
}

alpine-golang's People

Contributors

ladydascalie avatar lorenzob-jf avatar lushrjp avatar zeevallin avatar

Stargazers

 avatar

Watchers

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

Forkers

ladydascalie

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.