mirror of
https://github.com/mudler/luet.git
synced 2025-08-01 23:41:37 +00:00
Add target to create smaller binary
This commit is contained in:
parent
cc21e6fa5e
commit
d59cc42e22
@ -1,6 +1,7 @@
|
||||
FROM golang as builder
|
||||
RUN apt-get update && apt-get install upx
|
||||
ADD . /luet
|
||||
RUN cd /luet && make build
|
||||
RUN cd /luet && make build-small
|
||||
|
||||
FROM scratch
|
||||
ENV LUET_NOLOCK=true
|
||||
|
10
Makefile
10
Makefile
@ -1,7 +1,7 @@
|
||||
|
||||
# go tool nm ./luet | grep Commit
|
||||
LDFLAGS += -X "github.com/mudler/luet/cmd.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
|
||||
LDFLAGS += -X "github.com/mudler/luet/cmd.BuildCommit=$(shell git rev-parse HEAD)"
|
||||
override LDFLAGS += -X "github.com/mudler/luet/cmd.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
|
||||
override LDFLAGS += -X "github.com/mudler/luet/cmd.BuildCommit=$(shell git rev-parse HEAD)"
|
||||
|
||||
NAME ?= luet
|
||||
PACKAGE_NAME ?= $(NAME)
|
||||
@ -9,7 +9,6 @@ PACKAGE_CONFLICT ?= $(PACKAGE_NAME)-beta
|
||||
REVISION := $(shell git rev-parse --short HEAD || echo dev)
|
||||
VERSION := $(shell git describe --tags || echo $(REVISION))
|
||||
VERSION := $(shell echo $(VERSION) | sed -e 's/^v//g')
|
||||
ITTERATION := $(shell date +%s)
|
||||
BUILD_PLATFORMS ?= -osarch="linux/amd64" -osarch="linux/386" -osarch="linux/arm"
|
||||
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@ -66,6 +65,11 @@ deps:
|
||||
build:
|
||||
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)'
|
||||
|
||||
.PHONY: build-small
|
||||
build-small:
|
||||
@$(MAKE) LDFLAGS+="-s -w" build
|
||||
upx --brute $(NAME)
|
||||
|
||||
.PHONY: image
|
||||
image:
|
||||
docker build --rm -t luet/base .
|
||||
|
Loading…
Reference in New Issue
Block a user