Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Rework the build system to set the firecracker version only in one pl…
Browse files Browse the repository at this point in the history
…ace, and make the image name reference the fc version
  • Loading branch information
luxas committed May 31, 2019
1 parent c73638c commit 1ebd877
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ RUN apk add --no-cache iproute2

VOLUME /var/lib/firecracker

ARG FIRECRACKER_VERSION=v0.16.0
ADD https://github.com/firecracker-microvm/firecracker/releases/download/${FIRECRACKER_VERSION}/firecracker /ignite/firecracker
ARG FIRECRACKER_VERSION
ADD https://github.com/firecracker-microvm/firecracker/releases/download/${FIRECRACKER_VERSION}/firecracker-${FIRECRACKER_VERSION} /ignite/firecracker

# The ignite binary should be bind-mounted over /ignite/ignite
RUN touch /ignite/ignite && \
chmod +x /ignite/firecracker && \
ln -s /ignite/firecracker /usr/local/bin/firecracker && \
ln -s /ignite/ignite /usr/local/bin/ignite

ENTRYPOINT ["/ignite/ignite", "container"]
ENTRYPOINT ["/ignite/ignite", "container"]
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
UID_GID?=$(shell id -u):$(shell id -g)
FIRECRACKER_VERSION:=$(shell cat hack/FIRECRACKER_VERSION)
GO_VERSION=1.12

all: binary
build:
docker build -t ignite .

binary:
docker run -it --rm -v $(shell pwd):/build -w /build golang:1.12 sh -c "\
docker run -it --rm -v $(shell pwd):/build -w /build golang:${GO_VERSION} sh -c "\
make ignite && \
chown ${UID_GID} bin/ignite"

# Make make execute this target although the file already exists.
.PHONY: bin/ignite
ignite: bin/ignite
bin/ignite:
CGO_ENABLED=0 go build -mod=vendor -ldflags "$(shell ./hack/ldflags.sh)" -o bin/ignite ./cmd/ignite

.PHONY: bin/ignite
image:
docker build -t weaveworks/ignite:${FIRECRACKER_VERSION} \
--build-arg FIRECRACKER_VERSION=${FIRECRACKER_VERSION} .
3 changes: 2 additions & 1 deletion cmd/ignite/run/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/luxas/ignite/pkg/constants"
"github.com/luxas/ignite/pkg/util"
"github.com/luxas/ignite/pkg/version"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -32,7 +33,7 @@ func Start(so *StartOptions) error {
fmt.Sprintf("--stop-timeout=%d", constants.STOP_TIMEOUT+constants.IGNITE_TIMEOUT),
"--privileged",
"--device=/dev/kvm",
"ignite",
"weaveworks/ignite:"+version.GetFirecracker().String(),
so.VM.ID,
}

Expand Down
1 change: 1 addition & 0 deletions hack/FIRECRACKER_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.16.0
4 changes: 4 additions & 0 deletions hack/ldflags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ ldflags() {
)
fi

# Set the desired Firecracker version
SCRIPT_DIR=$( dirname "${BASH_SOURCE[0]}" )
ldflags+=($(ldflag "firecrackerVersion" "$(cat ${SCRIPT_DIR}/FIRECRACKER_VERSION)"))

# The -ldflags parameter takes a single string, so join the output.
echo "${ldflags[*]-}"
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var (
gitCommit = ""
gitTreeState = ""
buildDate = ""
firecrackerVersion = ""
)

// Info stores information about a component's version
Expand Down Expand Up @@ -50,8 +51,6 @@ func GetIgnite() Info {
// GetFirecracker returns firecracker's version
func GetFirecracker() Info {
return Info{
Major: "0",
Minor: "16",
GitVersion: "v0.16.0",
GitVersion: firecrackerVersion,
}
}

0 comments on commit 1ebd877

Please sign in to comment.