Skip to content

Commit

Permalink
Update image build for latest gokr-packer
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 18, 2021
1 parent 4891676 commit 52085b3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@ jobs:
go-version: ^1.14
id: go

- name: Build Image
- name: Prepare Image
run: |
make prepare-image
sed -e 's/-ld.*$/& -X github.com/andig/evcc/server/updater.Password=${{ secrets.IMAGE_PASS }}/' buildflags/github.com/andig/evcc/buildflags.txt > buildflags/github.com/andig/evcc/buildflags.txt
mkdir /home/runner/.config/gokrazy
echo ${{ secrets.IMAGE_PASS }}> /home/runner/.config/gokrazy/http-password.txt
make image
- name: Build Image
run: make image

- name: Build Root Filesystem
run: make image-rootfs
Expand Down
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
__debug_bin
.vscode
*.json
!package*.json
*.log
.cache
*.py
*.log
*.json
*.yaml
!package*.json
!evcc.dist.yaml
evcc
evcc_*
flags/*
buildflags/*
linux-*.Dockerfile
!evcc.dist.yaml
dist
*.py
node_modules
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ TAG_NAME := $(shell test -d .git && git describe --abbrev=0 --tags)
SHA := $(shell test -d .git && git rev-parse --short HEAD)
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
BUILD_ARGS := -tags=release -ldflags '-X "github.com/andig/evcc/server.Version=$(VERSION)" -X "github.com/andig/evcc/server.Commit=$(SHA)"'
BUILD_TAGS := -tags=release
LD_FLAGS := -X github.com/andig/evcc/server.Version=$(VERSION) -X github.com/andig/evcc/server.Commit=$(SHA)
BUILD_ARGS := -ldflags='$(LD_FLAGS)'

# docker
DOCKER_IMAGE := andig/evcc
Expand All @@ -17,7 +19,7 @@ TARGETS := arm.v6,arm.v8,amd64
# image
IMAGE_FILE := evcc_$(TAG_NAME).image
IMAGE_ROOTFS := evcc_$(TAG_NAME).rootfs
IMAGE_OPTIONS := -hostname evcc -http_port 8080 github.com/gokrazy/serial-busybox github.com/andig/brokenglass github.com/andig/evcc
IMAGE_OPTIONS := -hostname evcc -http_port 8080 github.com/gokrazy/serial-busybox github.com/gokrazy/breakglass github.com/andig/evcc

default: clean install npm assets lint test build

Expand Down Expand Up @@ -50,7 +52,7 @@ assets:

build:
@echo Version: $(VERSION) $(BUILD_DATE)
go build -v $(BUILD_ARGS)
go build -v $(BUILD_TAGS) $(BUILD_ARGS)

release-test:
goreleaser --snapshot --skip-publish --rm-dist
Expand All @@ -73,23 +75,22 @@ publish-images:
seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "latest" -v "$(TAG_NAME)" --targets=$(TARGETS)

image-prepare:
go get github.com/gokrazy/tools/cmd/gokr-packer@latest
mkdir -p flags/github.com/gokrazy/breakglass
echo "-forward=private-network" > flags/github.com/gokrazy/breakglass/flags.txt
mkdir -p buildflags/github.com/andig/evcc
echo "$(BUILD_TAGS),gokrazy" > buildflags/github.com/andig/evcc/buildflags.txt
echo "-ldflags=$(LD_FLAGS)" >> buildflags/github.com/andig/evcc/buildflags.txt

image:
go get github.com/gokrazy/tools/cmd/gokr-packer
mkdir -p buildargs/github.com/andig/evcc
echo "$(BUILD_ARGS)" > buildargs/github.com/andig/evcc/buildargs.txt
gokr-packer -overwrite=$(IMAGE_FILE) -target_storage_bytes=1258299392 $(IMAGE_OPTIONS)

# create filesystem
loop=$$(sudo losetup --find --show -P $(IMAGE_FILE)); sudo mkfs.ext4 $${loop}p4
gzip -f -k $(IMAGE_FILE)
gzip -f $(IMAGE_FILE)

image-rootfs:
mkdir -p buildargs/github.com/andig/evcc
echo "$(BUILD_ARGS)" > buildargs/github.com/andig/evcc/buildargs.txt
gokr-packer -overwrite_root=$(IMAGE_ROOTFS) $(IMAGE_OPTIONS)
gzip -f -k $(IMAGE_ROOTFS)
gzip -f $(IMAGE_ROOTFS)

image-update:
mkdir -p buildargs/github.com/andig/evcc
echo "$(BUILD_ARGS)" > buildargs/github.com/andig/evcc/buildargs.txt
gokr-packer -update yes $(IMAGE_OPTIONS)
4 changes: 3 additions & 1 deletion server/updater/gokrazy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ const (
MB = 1024 * 1024
RootOffset = 8192*512 + 100*MB
RootSize = 500 * MB
RootFS = "evcc_%s.rootfs.gz"
)

RootFS = "evcc_%s.rootfs.gz"
var (
Password = "FIat2WTD8i3tJikkvIJI"
Port = 8080
)
Expand Down

0 comments on commit 52085b3

Please sign in to comment.