Skip to content

Commit

Permalink
crosscompile for different architecures
Browse files Browse the repository at this point in the history
  • Loading branch information
nbari committed May 26, 2018
1 parent 5248575 commit 6a26c7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Dockerfile
Expand Up @@ -5,45 +5,45 @@ WORKDIR /go/src/github.com/immortal/immortal
COPY . .
RUN dep ensure --vendor-only
RUN chown -R toor:toor /go
RUN mkdir /immortal
ARG VERSION=0.0.0
ENV VERSION="${VERSION}"
USER toor
RUN go test -race -v
USER root
RUN go build -ldflags "-s -w -X main.version=${VERSION}" -o /immortal/immortal cmd/immortal/main.go \
&& go build -ldflags "-s -w -X main.version=${VERSION}" -o /immortal/immortalctl cmd/immortalctl/main.go \
&& go build -ldflags "-s -w -X main.version=${VERSION}" -o /immortal/immortaldir cmd/immortaldir/main.go
RUN make build-linux
RUN mv man /
RUN mv build /

FROM ruby:2.3
RUN apt-get update && apt-get install -y --no-install-recommends -q build-essential ca-certificates git rpm
ARG VERSION=0.0.0
ENV VERSION="${VERSION}"
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $BUNDLE_BIN:$PATH
RUN gem install --quiet --no-document fpm
RUN gem install --quiet --no-document package_cloud
RUN mkdir /build
RUN mkdir -p /source/etc/immortal \
&& mkdir -p /source/usr/bin \
&& mkdir -p /source/tmp/immortal \
&& mkdir -p /source/usr/local/man/man8
COPY --from=builder /immortal/* /source/usr/bin/
COPY --from=builder /build /build
COPY --from=builder /man/* /source/usr/local/man/man8/
RUN mkdir deb-package
WORKDIR deb-package
RUN git clone https://github.com/immortal/packages.git scripts
RUN cp scripts/* /source/tmp/immortal
RUN fpm --output-type deb \
--architecture all \
--input-type dir --chdir /source \
--input-type dir \
--name immortal \
--version ${VERSION} \
--description 'A *nix cross-platform (OS agnostic) supervisor' \
--url 'https://immortal.run' \
--after-install scripts/after-install.sh \
--before-remove scripts/before-remove.sh \
--package immortal-${VERSION}.deb
--package immortal-${VERSION}.deb \
--chdir / \
/source/=/ /build/386/=/usr/bin
8 changes: 8 additions & 0 deletions Makefile
Expand Up @@ -23,6 +23,14 @@ build: get
${GO} build -ldflags "-s -w -X main.version=${VERSION}" -o immortalctl cmd/immortalctl/main.go;
${GO} build -ldflags "-s -w -X main.version=${VERSION}" -o immortaldir cmd/immortaldir/main.go;

build-linux:
for arch in 386 amd64 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le; do \
mkdir -p build/$${arch}; \
GOOS=linux GOARCH=$${arch} ${GO} build -ldflags "-s -w -X main.version=${VERSION}" -o build/$${arch}/immortal cmd/immortal/main.go; \
GOOS=linux GOARCH=$${arch} ${GO} build -ldflags "-s -w -X main.version=${VERSION}" -o build/$${arch}/immortalctl cmd/immortalctl/main.go; \
GOOS=linux GOARCH=$${arch} ${GO} build -ldflags "-s -w -X main.version=${VERSION}" -o build/$${arch}/immortaldir cmd/immortaldir/main.go; \
done

clean:
${GO} clean -i
@rm -rf immortal immortalctl immortaldir *.debug *.out build debian
Expand Down

0 comments on commit 6a26c7a

Please sign in to comment.