added build script for container (buildah)
This commit is contained in:
3
Makefile
3
Makefile
@@ -1,11 +1,10 @@
|
||||
#GOFLAGS=""
|
||||
LDFLAGS=-ldflags "-s -w"
|
||||
BINARY=metrorama
|
||||
|
||||
.DEFAULT_GOAL: $(BINARY)
|
||||
|
||||
$(BINARY): clean
|
||||
go build ${GOFLAGS} ${LDFLAGS} -o ${BINARY}
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build ${GOFLAGS} ${LDFLAGS} -o ${BINARY}
|
||||
|
||||
install:
|
||||
go install ${GOFLAGS} ${LDFLAGS} -o ${BINARY}
|
||||
|
||||
24
build.sh
Executable file
24
build.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Remember to run buildah unshare before launching this
|
||||
# Build container
|
||||
echo "Start creating first stage "
|
||||
buildctrl=$(buildah from golang:1.15.2)
|
||||
buildmnt=$(buildah mount $buildctrl)
|
||||
|
||||
buildah copy $buildctrl *.go .
|
||||
buildah copy $buildctrl Makefile .
|
||||
buildah run $buildctrl make deps
|
||||
buildah run $buildctrl make
|
||||
|
||||
# Runtime container
|
||||
echo "Start creating second stage"
|
||||
buildctrl2=$(buildah from alpine:latest)
|
||||
buildmnt2=$(buildah mount $builctrl2)
|
||||
|
||||
buildah copy $buildctrl2 $buildmnt/go/metrorama
|
||||
buildah config --cmd ./metrorama $buildctrl2
|
||||
buildah config --port 8080 $buildctrl2
|
||||
buildah unmount $buildctrl
|
||||
buildah unmount $buildctrl2
|
||||
buildah commit $buildctrl2 metrorama:latest
|
||||
buildah rm $buildctrl $buildctrl2
|
||||
Reference in New Issue
Block a user