Comments (9)
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.
@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.
+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.
@lorenz Using exec 1>/dev/null
or exec 1>&2
at the top of your command might be nice.
from forego.
@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.
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.
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.
Someone figure out how to do this with Equinox and I'll add it! /cc @inconshreveable
from forego.
Yeah, I have this same problem with ngrok. Your options (at the moment) are:
CGO_ENABLED=0
for all builds. This breaksos/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)
- Latest forego version immediately crashes for rails / node app HOT 3
- PORT env var dependent on the position in the Procfile HOT 2
- forego only extend the first shell variable on the right side of the equal sign in .env file
- Forego adds sleeping bash process for every application (read from .profile) HOT 2
- How to pause or stop a process ?
- Windows Ubuntu
- does not pass on signal to children
- npm script hangs on Windows with "Terminate batch job (Y/N)?" prompt
- Forego i386 binary? HOT 2
- Could you create a new version tag which is compatible with go modules? HOT 1
- Official Forego Docker image
- "forego start" exits immediately with doing nothing on macOS HOT 2
- equinox.io shutting down, publish builds elsewhere? HOT 3
- Download page missing HOT 2
- Prevent environment variables from being overriden?
- request a new release HOT 1
- Immediate exit when using reflex OSX HOT 3
- forego exit In osx HOT 1
- child process doesn't exit in osx HOT 1
- Restart crashed processes HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forego.