Created
November 4, 2015 21:38
-
-
Save arledesma/7a6752194c3cb54e6019 to your computer and use it in GitHub Desktop.
Dockerfile for cross-compiling and packaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cross-compile go with fpm for packaging rpm and deb files | |
# | |
FROM ubuntu:trusty | |
# | |
# https://hub.docker.com/r/neroinc/ubuntu-crosscompile/ | |
# | |
# Packaged dependencies | |
RUN apt-get update | |
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \ | |
automake \ | |
build-essential \ | |
curl \ | |
ca-certificates \ | |
git \ | |
mercurial \ | |
--no-install-recommends; \ | |
apt-get clean | |
# Install ARM cross compiler and i386 header files | |
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \ | |
gcc-multilib \ | |
libc6-dev-i386 \ | |
gcc-4.7-multilib-arm-linux-gnueabi \ | |
gcc-4.7-multilib-arm-linux-gnueabihf \ | |
g++-4.7-multilib-arm-linux-gnueabi \ | |
g++-4.7-multilib-arm-linux-gnueabihf \ | |
--no-install-recommends; \ | |
apt-get clean | |
# Install packaging dependencies | |
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \ | |
rpm \ | |
# ruby \ | |
ruby-dev \ | |
dos2unix; \ | |
apt-get clean | |
RUN gem install fpm | |
# See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/778047 | |
RUN ln -s /usr/include/asm-generic /usr/include/asm | |
# | |
# https://hub.docker.com/r/neroinc/ubuntu-golang-crosscompile/ | |
# | |
# Install Go | |
RUN mkdir /goroot && curl https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1 | |
RUN mkdir /gopath | |
ENV GOROOT /goroot | |
ENV GOPATH /gopath | |
ENV PATH $GOROOT/bin/:$GOPATH/bin/:$PATH | |
# http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1 | |
# https://github.com/davecheney/golang-crosscompile | |
# Add crosscompile.bash script to profile for interactive login | |
RUN curl https://raw.githubusercontent.com/davecheney/golang-crosscompile/master/crosscompile.bash > /etc/profile.d/crosscompile.bash | |
# Source go cross-compile and build go libraries | |
RUN bash -c 'source /etc/profile.d/crosscompile.bash; go-crosscompile-build-all' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment