next #5
|
@ -3,3 +3,4 @@
|
|||
/buildimage
|
||||
/dockerdeps
|
||||
/tmp
|
||||
*.docker.tzst
|
||||
|
|
|
@ -4,3 +4,5 @@ vendor
|
|||
/tmp
|
||||
/buildimage/go.mod
|
||||
/buildimage/go.sum
|
||||
*.docker.tzst
|
||||
*.tzst
|
||||
|
|
50
Dockerfile
50
Dockerfile
|
@ -1,29 +1,47 @@
|
|||
## lint image
|
||||
FROM golangci/golangci-lint:v1.50.1
|
||||
FROM golang:1.19.3-bullseye AS cacher
|
||||
|
||||
ENV GOPATH /go
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
apt update && apt install -y make zstd curl unzip
|
||||
RUN mkdir -p /build
|
||||
WORKDIR /build
|
||||
COPY ./ ./
|
||||
RUN golangci-lint run
|
||||
|
||||
## build image:
|
||||
FROM sneak/mfer-build AS builder
|
||||
# install newer protoc
|
||||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v21.10/protoc-21.10-linux-aarch_64.zip && \
|
||||
unzip *.zip -d /usr/local && rm -v *.zip && protoc --version
|
||||
|
||||
RUN go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
|
||||
|
||||
COPY ./go.mod .
|
||||
COPY ./go.sum .
|
||||
|
||||
RUN --mount=type=cache,target=/go/pkg go mod download -x
|
||||
RUN go env
|
||||
## build image
|
||||
FROM golang:1.19.3-bullseye AS builder
|
||||
|
||||
COPY --from=cacher /usr/local /usr/local
|
||||
COPY --from=cacher /usr/bin /usr/bin
|
||||
COPY --from=cacher /go/bin /go/bin
|
||||
COPY --from=cacher /build /build
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
|
||||
COPY ./ ./
|
||||
# don't lint again during build because there's no golangci-lint in this
|
||||
# image and we already did it in a previous stage
|
||||
#RUN make lint
|
||||
RUN make mfer.cmd
|
||||
#RUN go mod vendor
|
||||
RUN tar -c . | bzip2 > /src.tbz2
|
||||
RUN --mount=type=cache,target=/go/pkg go mod download -x && go mod tidy && cd mfer && go generate .
|
||||
RUN --mount=type=cache,target=/go/pkg make mfer.cmd && go mod vendor
|
||||
RUN tar -c . | zstdmt -19 > /src.tzst
|
||||
|
||||
## lint image
|
||||
FROM golangci/golangci-lint:v1.50.1 AS linter
|
||||
|
||||
COPY --from=cacher /build /build
|
||||
WORKDIR /build
|
||||
RUN golangci-lint run
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /src.tbz2 /src.tbz2
|
||||
COPY --from=builder /src.tzst /src.tzst
|
||||
COPY --from=builder /build/mfer.cmd /mfer
|
||||
ENTRYPOINT ["/mfer"]
|
||||
|
||||
|
|
28
Makefile
28
Makefile
|
@ -1,8 +1,11 @@
|
|||
export DOCKER_BUILDKIT := 1
|
||||
export PROGRESS_NO_TRUNC := 1
|
||||
GOPATH := $(shell go env GOPATH)
|
||||
export PATH := $(PATH):$(GOPATH)/bin
|
||||
PROTOC_GEN_GO := $(GOPATH)/bin/protoc-gen-go
|
||||
|
||||
SOURCEFILES := mfer/*.go mfer/*.proto internal/*/*.go cmd/*/*.go go.mod go.sum
|
||||
|
||||
ARCH := $(shell uname -m)
|
||||
GITREV := $(shell git describe --always --dirty=-dirty)
|
||||
APPNAME := mfer
|
||||
|
@ -12,26 +15,30 @@ GOLDFLAGS += -X main.Version=0.1.0
|
|||
GOLDFLAGS += -X main.Gitrev=$(GITREV)
|
||||
GOFLAGS := -ldflags "$(GOLDFLAGS)"
|
||||
|
||||
default: test
|
||||
.PHONY: docker default run ci test fixme
|
||||
|
||||
default: fmt test
|
||||
|
||||
run: ./mfer.cmd
|
||||
./$<
|
||||
./$< gen --ignore-dotfiles
|
||||
|
||||
test: fmt
|
||||
ci: test
|
||||
|
||||
test:
|
||||
go test -v --timeout 3s ./...
|
||||
|
||||
$(PROTOC_GEN_GO):
|
||||
test -e $(PROTOC_GEN_GO) || go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
test -e $(PROTOC_GEN_GO) || go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
|
||||
|
||||
fixme:
|
||||
@grep -nir fixme . | grep -v Makefile
|
||||
|
||||
devprereqs:
|
||||
which gofumpt || go install -v mvdan.cc/gofumpt@latest
|
||||
which golangci-lint || go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
which golangci-lint || go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
|
||||
|
||||
mfer.cmd: mfer/*.go internal/*/*.go cmd/*/*.go
|
||||
mfer.cmd: $(SOURCEFILES)
|
||||
protoc --version
|
||||
cd mfer && go generate .
|
||||
make test
|
||||
|
@ -40,7 +47,8 @@ mfer.cmd: mfer/*.go internal/*/*.go cmd/*/*.go
|
|||
clean:
|
||||
rm -rfv mfer/*.pb.go mfer.cmd cmd/mfer/mfer
|
||||
|
||||
fmt: devprereqs
|
||||
fmt:
|
||||
devprereqs
|
||||
gofumpt -l -w mfer internal cmd
|
||||
golangci-lint run --fix
|
||||
-prettier -w *.json
|
||||
|
@ -50,9 +58,13 @@ lint:
|
|||
golangci-lint run
|
||||
sh -c 'test -z "$$(gofmt -l .)"'
|
||||
|
||||
docker:
|
||||
docker: sneak-mfer.$(ARCH).docker.tzst
|
||||
|
||||
sneak-mfer.$(ARCH).docker.tzst: $(SOURCEFILES)
|
||||
bash -x bin/docker-prereqs.sh
|
||||
docker build .
|
||||
docker build --progress plain -t sneak/mfer .
|
||||
docker save sneak/mfer | pv | zstdmt -19 > $@
|
||||
du -sh $@
|
||||
|
||||
godoc:
|
||||
open http://127.0.0.1:6060
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
set -euxo pipefail
|
||||
GOI="golang:1.19.3-bullseye"
|
||||
CII="golangci/golangci-lint:v1.50.1"
|
||||
BII="sneak/mfer-build"
|
||||
|
||||
if [[ ! -d "$DOCKER_IMAGE_CACHE_DIR" ]]; then
|
||||
mkdir -p "$DOCKER_IMAGE_CACHE_DIR"
|
||||
|
@ -22,16 +21,6 @@ function buildImageCache() {
|
|||
docker save $CII | pv | zstdmt -19 > $DICD/ci.tzst.tmp && \
|
||||
mv $DICD/ci.tzst.tmp $DICD/ci.tzst
|
||||
fi
|
||||
|
||||
if [[ ! -e "$DICD/build.tzst" ]]; then
|
||||
go mod download -x
|
||||
cd buildimage
|
||||
cp ../go.mod ../go.sum .
|
||||
docker build -t $BII . && rm -rf go.mod go.sum && \
|
||||
cd .. && \
|
||||
docker save $BII | pv | zstdmt -19 > $DICD/build.tzst.tmp && \
|
||||
mv $DICD/build.tzst.tmp $DICD/build.tzst
|
||||
fi
|
||||
}
|
||||
|
||||
function loadImageCache() {
|
||||
|
@ -40,9 +29,6 @@ function loadImageCache() {
|
|||
|
||||
docker image ls $GOI || \
|
||||
zstdmt -d --stdout $DICD/go.tzst | pv | docker load
|
||||
|
||||
docker image ls $BII || \
|
||||
zstdmt -d --stdout $DICD/build.tzst | pv | docker load
|
||||
}
|
||||
|
||||
buildImageCache
|
||||
|
|
23
go.mod
23
go.mod
|
@ -1,6 +1,6 @@
|
|||
module git.eeqj.de/sneak/mfer
|
||||
|
||||
go 1.16
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/apex/log v1.9.0
|
||||
|
@ -10,4 +10,25 @@ require (
|
|||
github.com/stretchr/testify v1.8.1
|
||||
github.com/urfave/cli/v2 v2.3.0
|
||||
google.golang.org/protobuf v1.28.1
|
||||
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/atomicgo/cursor v0.0.1 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
|
||||
github.com/fatih/color v1.7.0 // indirect
|
||||
github.com/gookit/color v1.4.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.2 // indirect
|
||||
github.com/mattn/go-isatty v0.0.8 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.0.1 // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
golang.org/x/text v0.3.4 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
@ -20,6 +20,7 @@ message MFFileOuter {
|
|||
// and not for cryptographic integrity.
|
||||
int64 size = 103;
|
||||
bytes sha256 = 104;
|
||||
bytes deleteme = 105;
|
||||
|
||||
// 2xx for optional manifest root attributes
|
||||
// think we might use gosignify instead of gpg:
|
||||
|
|
Loading…
Reference in New Issue