mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 11:44:51 +00:00
15
Makefile
15
Makefile
@@ -9,6 +9,9 @@ DEV_DOCKERFILE = $(PROJECT_DIR)/docker/Dockerfile.development
|
|||||||
TEST_IMAGE = local/pspy-testing:latest
|
TEST_IMAGE = local/pspy-testing:latest
|
||||||
TEST_DOCKERFILE = $(PROJECT_DIR)/docker/Dockerfile.testing
|
TEST_DOCKERFILE = $(PROJECT_DIR)/docker/Dockerfile.testing
|
||||||
|
|
||||||
|
VERSION = `git describe --tags --always || echo "unknown"`
|
||||||
|
BUILD_SHA = `git rev-parse HEAD || echo "unknown"`
|
||||||
|
|
||||||
# Run unit test and integration test inside container
|
# Run unit test and integration test inside container
|
||||||
test:
|
test:
|
||||||
docker build -f $(TEST_DOCKERFILE) -t $(TEST_IMAGE) .
|
docker build -f $(TEST_DOCKERFILE) -t $(TEST_IMAGE) .
|
||||||
@@ -38,7 +41,7 @@ example:
|
|||||||
# builds one set of static binaries that should work on any system without dependencies, but are huge
|
# builds one set of static binaries that should work on any system without dependencies, but are huge
|
||||||
# builds another set of binaries that are as small as possible, but may not work
|
# builds another set of binaries that are as small as possible, but may not work
|
||||||
build:
|
build:
|
||||||
sh -c "if ! docker image ls | grep '$(BUILD_IMAGE)' | cut -d ':' -f1; then echo 'building build image'; docker build -f $(BUILD_DOCKERFILE) -t $(BUILD_IMAGE) .; fi"
|
# sh -c "if ! docker image ls | grep '$(BUILD_IMAGE)' | cut -d ':' -f1; then echo 'building build image'; docker build -f $(BUILD_DOCKERFILE) -t $(BUILD_IMAGE) .; fi"
|
||||||
|
|
||||||
mkdir -p $(PROJECT_DIR)/bin
|
mkdir -p $(PROJECT_DIR)/bin
|
||||||
docker run -it \
|
docker run -it \
|
||||||
@@ -47,8 +50,8 @@ build:
|
|||||||
-w "/go/src/github.com/dominicbreuker" \
|
-w "/go/src/github.com/dominicbreuker" \
|
||||||
--env CGO_ENABLED=0 \
|
--env CGO_ENABLED=0 \
|
||||||
--env GOOS=linux \
|
--env GOOS=linux \
|
||||||
--env GOARCH=386 \
|
--env GOARCH=386 \
|
||||||
$(BUILD_IMAGE) /bin/sh -c "go build -a -ldflags '-extldflags \"-static\"' -o pspy/bin/pspy32 pspy/main.go"
|
$(BUILD_IMAGE) /bin/sh -c "go build -a -ldflags '-s -w -X main.version=${VERSION} -X main.commit=${BUILD_SHA} -extldflags \"-static\"' -o pspy/bin/pspy32 pspy/main.go"
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--rm \
|
--rm \
|
||||||
-v $(PROJECT_DIR):/go/src/github.com/dominicbreuker/pspy \
|
-v $(PROJECT_DIR):/go/src/github.com/dominicbreuker/pspy \
|
||||||
@@ -56,18 +59,18 @@ build:
|
|||||||
--env CGO_ENABLED=0 \
|
--env CGO_ENABLED=0 \
|
||||||
--env GOOS=linux \
|
--env GOOS=linux \
|
||||||
--env GOARCH=amd64 \
|
--env GOARCH=amd64 \
|
||||||
$(BUILD_IMAGE) /bin/sh -c "go build -a -ldflags '-extldflags \"-static\"' -o pspy/bin/pspy64 pspy/main.go"
|
$(BUILD_IMAGE) /bin/sh -c "go build -a -ldflags '-s -w -X main.version=${VERSION} -X main.commit=${BUILD_SHA} -extldflags \"-static\"' -o pspy/bin/pspy64 pspy/main.go"
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--rm \
|
--rm \
|
||||||
-v $(PROJECT_DIR):/go/src/github.com/dominicbreuker/pspy \
|
-v $(PROJECT_DIR):/go/src/github.com/dominicbreuker/pspy \
|
||||||
-w "/go/src/github.com/dominicbreuker" \
|
-w "/go/src/github.com/dominicbreuker" \
|
||||||
--env GOOS=linux \
|
--env GOOS=linux \
|
||||||
--env GOARCH=386 \
|
--env GOARCH=386 \
|
||||||
$(BUILD_IMAGE) /bin/sh -c "go build -ldflags '-w -s' -o pspy/bin/pspy32s pspy/main.go && upx pspy/bin/pspy32s"
|
$(BUILD_IMAGE) /bin/sh -c "go build -ldflags '-w -s -X main.version=${VERSION} -X main.commit=${BUILD_SHA}' -o pspy/bin/pspy32s pspy/main.go && upx pspy/bin/pspy32s"
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--rm \
|
--rm \
|
||||||
-v $(PROJECT_DIR):/go/src/github.com/dominicbreuker/pspy \
|
-v $(PROJECT_DIR):/go/src/github.com/dominicbreuker/pspy \
|
||||||
-w "/go/src/github.com/dominicbreuker" \
|
-w "/go/src/github.com/dominicbreuker" \
|
||||||
--env GOOS=linux \
|
--env GOOS=linux \
|
||||||
--env GOARCH=amd64 \
|
--env GOARCH=amd64 \
|
||||||
$(BUILD_IMAGE) /bin/sh -c "go build -ldflags '-w -s' -o pspy/bin/pspy64s pspy/main.go && upx pspy/bin/pspy64s"
|
$(BUILD_IMAGE) /bin/sh -c "go build -ldflags '-w -s -X main.version=${VERSION} -X main.commit=${BUILD_SHA}' -o pspy/bin/pspy64s pspy/main.go && upx pspy/bin/pspy64s"
|
||||||
|
|||||||
10
main.go
10
main.go
@@ -1,7 +1,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/dominicbreuker/pspy/cmd"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/dominicbreuker/pspy/cmd"
|
||||||
|
)
|
||||||
|
|
||||||
|
var version string
|
||||||
|
var commit string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
fmt.Printf("pspy - version: %s - Commit SHA: %s\n", version, commit)
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user