Giter Site home page Giter Site logo

Comments (9)

lorenz avatar lorenz commented on June 16, 2024 1

Fully static stripped build (5.9MiB) now working :)

#!/bin/bash
docker run -i --rm golang:1.5.1 > forego <<END
apt-get update 1> /dev/null && apt-get install -yy musl-dev musl-tools 1> /dev/null
go get github.com/ddollar/forego 1> /dev/null
cd /go/src/github.com/ddollar/forego 1> /dev/null
CC=musl-gcc go build  --ldflags '-linkmode external -extldflags "-static -s"' 1> /dev/null
cat forego
END

This pulls golang:1.5.1, installs the appropriate musl tools, pulls forego and builds a stripped static binary and outputs it to the working directory. It could obviously be altered to take the input from a volume instead of downloading it.
The resulting binary works on every Linux with the same CPU architecture.

from forego.

lorenz avatar lorenz commented on June 16, 2024 1

@ddollar Can we get this new build process integrated for the new binary releases? There are no downsides to these binaries, they are even smaller than the ones you are currently distributing and they work absolutely everywhere where you have Linux x64, even on a bare kernel or in otherwise empty Docker images. I don't know how you build your binaries but you could just drop my code above into a bash script and you'd get a fully built version in the working directory.

from forego.

lorenz avatar lorenz commented on June 16, 2024

+1, would appreciate a musl build with static linking as glibc has its quirks with static linking and makes the binary really large

Nonstatic build for Alpine:

docker run -ti --name build-forego alpine:edge sh
# Enter Docker Shell
apk update && apk upgrade && apk add go musl-dev git
mkdir /go && export GOPATH=/go
go get github.com/ddollar/forego
# Leave Docker shell
docker cp build-forego:/go/bin/forego dist/forego

I'm working on the fully static one.

from forego.

md5 avatar md5 commented on June 16, 2024

@lorenz Using exec 1>/dev/null or exec 1>&2 at the top of your command might be nice.

from forego.

hmalphettes avatar hmalphettes commented on June 16, 2024

@md5 at the moment the console output of the script is only the error stream.
I think it comes in handy if things go wrong.

This is what it generates on my machine:

core@core-01 ~ $ ./build-forego.sh
debconf: delaying package configuration, since apt-utils is not installed

from forego.

md5 avatar md5 commented on June 16, 2024

I just realized that would mess with the final "cat" too.
On Nov 18, 2015 00:07, "Hugues Malphettes" [email protected] wrote:

@md5 https://github.com/md5 at the moment the console output of the
script is only the error stream.
I think it comes in handy if things go wrong.

This is what it generates on my machine:

core@core-01 ~ $ ./build-forego.sh
debconf: delaying package configuration, since apt-utils is not installed


Reply to this email directly or view it on GitHub
#65 (comment).

from forego.

thaJeztah avatar thaJeztah commented on June 16, 2024

Looks like there's work in progress on creating official alpine-based nginx images; https://github.com/nginxinc/docker-nginx/blob/master/mainline/alpine/Dockerfile, and ran into this; are there still plans to ship an alpine-compatible binary?

from forego.

ddollar avatar ddollar commented on June 16, 2024

Someone figure out how to do this with Equinox and I'll add it! /cc @inconshreveable

from forego.

inconshreveable avatar inconshreveable commented on June 16, 2024

Yeah, I have this same problem with ngrok. Your options (at the moment) are:

  • CGO_ENABLED=0 for all builds. This breaks os/user.Current and disables native certificate store lookups on darwin and forces use of the pure-Go resolver on non-windows platforms.
  • Create a separate channel 'stable-static' in equinox and release to both channels. Equinox forces unique version strings, so you'd just need to pass it ${VERSION}-static or something like that.

I have this problem with static builds and GOARM=5, so we'll get native support into equinox to deal with this problem, just not sure when it will land.

from forego.

Related Issues (20)

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.