Add makefile target for cross

Can be run with:

```
docker build --rm --force-rm -t notary .

docker run --rm -it \
    -v $(pwd)/cross:/go/src/github.com/docker/notary/cross \
    notary \
    make cross
```

Signed-off-by: Jessica Frazelle <princess@docker.com>
This commit is contained in:
Jessica Frazelle 2015-07-17 07:11:51 -07:00
parent 541920c770
commit 7a588ab223
5 changed files with 26 additions and 24 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/cmd/notary-server/notary-server
cover
bin
cross
*.swp

View File

@ -1,7 +1,7 @@
FROM golang:1.4.2-cross
RUN apt-get update && apt-get install -y \
libltdl-dev \
libltdl-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

View File

@ -2,14 +2,17 @@
PREFIX?=$(shell pwd)
# Used to populate version variable in main package.
GO_LDFLAGS=-ldflags "-X `go list ./version`.Version `git describe --match 'v[0-9]*' --dirty='.m' --always`"
GO_LDFLAGS=-ldflags "-w -X `go list ./version`.Version `git describe --match 'v[0-9]*' --dirty='.m' --always`"
GO_LDFLAGS_STATIC=-ldflags "-w -extldflags -static -X `go list ./version`.Version `git describe --match 'v[0-9]*' --dirty='.m' --always`"
GOOSES = darwin freebsd linux windows
GOARCHS = amd64 386
.PHONY: clean all fmt vet lint build test binaries
.PHONY: clean all fmt vet lint build test binaries cross
.DEFAULT: default
all: AUTHORS clean fmt vet fmt lint build test binaries
AUTHORS: .git/HEAD
git log --format='%aN <%aE>' | sort -fu > $@
git log --format='%aN <%aE>' | sort -fu > $@
# This only needs to be generated by hand when cutting full releases.
version/version.go:
@ -62,6 +65,15 @@ clean-protos:
binaries: ${PREFIX}/bin/notary-server ${PREFIX}/bin/notary ${PREFIX}/bin/notary-signer
@echo "+ $@"
define template
mkdir -p ${PREFIX}/cross/$(1)/$(2);
GOOS=$(1) GOARCH=$(2) go build -o ${PREFIX}/cross/$(1)/$(2)/notary -a -tags "static_build netgo" -installsuffix netgo ${GO_LDFLAGS_STATIC} ./cmd/notary;
endef
cross:
$(foreach GOARCH,$(GOARCHS),$(foreach GOOS,$(GOOSES),$(call template,$(GOOS),$(GOARCH))))
clean:
@echo "+ $@"
@rm -rf "${PREFIX}/bin/notary-server" "${PREFIX}/bin/notary" "${PREFIX}/bin/notary-signer"

View File

@ -2,8 +2,8 @@ FROM golang
RUN apt-get update && apt-get install -y \
libltdl-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
COPY . /go/src/github.com/docker/notary

View File

@ -1,5 +1,4 @@
FROM diogomonica/golang-softhsm2
MAINTAINER Diogo Monica "diogo@docker.com"
# CHANGE-ME: Default values for SoftHSM2 PIN and SOPIN, used to initialize the first token
@ -9,22 +8,13 @@ ENV LIBDIR="/usr/local/lib/softhsm/"
# Install openSC and dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
autoconf \
automake \
libtool \
gtk-doc-tools \
gengetopt \
help2man \
libpcsclite-dev \
libzip-dev \
opensc \
libssl-dev \
usbutils \
vim \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
apt-get install -y \
libltdl-dev \
libpcsclite-dev \
opensc \
usbutils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Initialize the SoftHSM2 token on slod 0, using PIN and SOPIN varaibles
RUN softhsm2-util --init-token --slot 0 --label "test_token" --pin $PIN --so-pin $SOPIN
@ -39,5 +29,4 @@ RUN go install github.com/docker/notary/cmd/notary-signer
EXPOSE 4443
#ENTRYPOINT notary-signer -cert /go/src/github.com/docker/notary/fixtures/notary-signer.crt -key /go/src/github.com/docker/notary/fixtures/notary-signer.key -debug -pkcs11 /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so -pin 123456
ENTRYPOINT notary-signer -cert /go/src/github.com/docker/notary/fixtures/notary-signer.crt -key /go/src/github.com/docker/notary/fixtures/notary-signer.key -debug -pkcs11 $LIBDIR/libsofthsm2.so -pin 1234