Skip to content

Commit

Permalink
Remove -mod=vendor and mount pkg/mod instead
Browse files Browse the repository at this point in the history
See gotify/plugin-template#4
tl;dr: Using vendor makes plugins incompatible.
  • Loading branch information
jmattheis committed Mar 2, 2019
1 parent 5a59426 commit 4814fe8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Makefile
@@ -1,8 +1,12 @@
LICENSE_DIR=./licenses/
BUILD_DIR=./build/
BUILD_DIR=./build
DOCKER_DIR=./docker/
SHELL := /bin/bash
GO_VERSION=`cat GO_VERSION`
DOCKER_BUILD_IMAGE=gotify/build
DOCKER_WORKDIR=/proj
DOCKER_RUN=docker run --rm -v "$$PWD/.:${DOCKER_WORKDIR}" -v "`go env GOPATH`/pkg/mod/.:/go/pkg/mod:ro" -w ${DOCKER_WORKDIR}
DOCKER_GO_BUILD=go build -mod=readonly -a -installsuffix cgo -ldflags "$$LD_FLAGS"

test: test-coverage test-race test-js
check: check-go check-swagger check-js
Expand Down Expand Up @@ -62,33 +66,30 @@ extract-licenses:
done

package-zip: extract-licenses
for BUILD in $(shell find ${BUILD_DIR}*); do \
for BUILD in $(shell find ${BUILD_DIR}/*); do \
zip -j $$BUILD.zip $$BUILD ./LICENSE; \
zip -ur $$BUILD.zip ${LICENSE_DIR}; \
done

build-docker: require-version
cp ${BUILD_DIR}gotify-linux-amd64 ./docker/gotify-app
cp ${BUILD_DIR}/gotify-linux-amd64 ./docker/gotify-app
(cd ${DOCKER_DIR} && docker build -t gotify/server:latest -t gotify/server:${VERSION} .)
rm ${DOCKER_DIR}gotify-app

build-js:
(cd ui && npm run build)

vendor:
go mod vendor

build-linux-amd64: vendor
docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-linux-amd64 go build -mod=vendor -a -installsuffix cgo -ldflags "$$LD_FLAGS" -o build/gotify-linux-amd64 /proj
build-linux-amd64:
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-amd64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/gotify-linux-amd64 ${DOCKER_WORKDIR}

build-linux-arm-7: vendor
docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-linux-arm-7 go build -mod=vendor -a -installsuffix cgo -ldflags "$$LD_FLAGS" -o build/gotify-linux-arm-7 /proj
build-linux-arm-7:
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm-7 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/gotify-linux-arm-7 ${DOCKER_WORKDIR}

build-linux-arm64: vendor
docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-linux-arm64 go build -mod=vendor -a -installsuffix cgo -ldflags "$$LD_FLAGS" -o build/gotify-linux-arm64 /proj
build-linux-arm64:
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/gotify-linux-arm64 ${DOCKER_WORKDIR}

build-windows-amd64: vendor
docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-windows-amd64 go build -mod=vendor -a -installsuffix cgo -ldflags "$$LD_FLAGS" -o build/gotify-windows-amd64.exe /proj
build-windows-amd64:
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-windows-amd64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/gotify-windows-amd64.exe ${DOCKER_WORKDIR}

build: build-linux-arm-7 build-linux-amd64 build-linux-arm64 build-windows-amd64

Expand Down

0 comments on commit 4814fe8

Please sign in to comment.