mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
build: allow overriding the builder image and install patchelf
Groundwork for building outside an interactive terminal. - IMAGE_NAME becomes overridable so a prebuilt image can be used instead of building one locally - docker run no longer hardcodes -it on the app and support recipes: allocating a TTY fails where there is none. shell stays interactive - install patchelf, which server/build.sh needs to set the RPATH on the server binary
This commit is contained in:
11
Makefile
11
Makefile
@@ -3,10 +3,13 @@
|
|||||||
# Configuration
|
# Configuration
|
||||||
UID := $(shell id -u)
|
UID := $(shell id -u)
|
||||||
GID := $(shell id -g)
|
GID := $(shell id -g)
|
||||||
IMAGE_NAME := nanokvm-builder-local-$(UID)-$(GID)
|
# ?= so a prebuilt image can be used instead, e.g. a GHCR-cached builder in CI.
|
||||||
|
IMAGE_NAME ?= nanokvm-builder-local-$(UID)-$(GID)
|
||||||
PWD := $(shell pwd)
|
PWD := $(shell pwd)
|
||||||
|
|
||||||
# Docker run common parameters
|
# Docker run common parameters. Allocating a TTY breaks in environments without
|
||||||
|
# one, so it can be overridden with DOCKER_TTY=
|
||||||
|
DOCKER_TTY ?= -it
|
||||||
DOCKER_RUN_BASE := docker run -e UID=$(UID) -e GID=$(GID) -v $(PWD):/home/build/NanoKVM --rm
|
DOCKER_RUN_BASE := docker run -e UID=$(UID) -e GID=$(GID) -v $(PWD):/home/build/NanoKVM --rm
|
||||||
|
|
||||||
# Build the image with the host user's identity so entrypoint does not need
|
# Build the image with the host user's identity so entrypoint does not need
|
||||||
@@ -80,12 +83,12 @@ shell: check-root builder-image
|
|||||||
# Build Go application
|
# Build Go application
|
||||||
app: check-root builder-image
|
app: check-root builder-image
|
||||||
@echo "Building app..."
|
@echo "Building app..."
|
||||||
@$(DOCKER_RUN_BASE) -it $(IMAGE_NAME) /bin/bash -c '$(GO_BUILD_CMD)'
|
@$(DOCKER_RUN_BASE) $(DOCKER_TTY) $(IMAGE_NAME) /bin/bash -c '$(GO_BUILD_CMD)'
|
||||||
|
|
||||||
# Build hardware support libraries
|
# Build hardware support libraries
|
||||||
support: check-root builder-image
|
support: check-root builder-image
|
||||||
@echo "Building support..."
|
@echo "Building support..."
|
||||||
@$(DOCKER_RUN_BASE) -it $(IMAGE_NAME) /bin/bash -c '$(SUPPORT_BUILD_CMD)'
|
@$(DOCKER_RUN_BASE) $(DOCKER_TTY) $(IMAGE_NAME) /bin/bash -c '$(SUPPORT_BUILD_CMD)'
|
||||||
|
|
||||||
# Clean build artifacts
|
# Clean build artifacts
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ FROM ubuntu:24.04 AS base_apt
|
|||||||
# RUN echo 'Acquire::http::Proxy "http://cache.lan:3142";' > /etc/apt/apt.conf.d/00cacher
|
# RUN echo 'Acquire::http::Proxy "http://cache.lan:3142";' > /etc/apt/apt.conf.d/00cacher
|
||||||
RUN userdel -r ubuntu
|
RUN userdel -r ubuntu
|
||||||
RUN apt update \
|
RUN apt update \
|
||||||
&& apt install wget git cmake build-essential python3 python3-venv python3-pip autoconf automake libtool gosu -y
|
&& apt install wget git cmake build-essential python3 python3-venv python3-pip autoconf automake libtool gosu patchelf -y
|
||||||
|
|
||||||
ARG DOCKER_USER=build
|
ARG DOCKER_USER=build
|
||||||
ARG DOCKER_UID=1000
|
ARG DOCKER_UID=1000
|
||||||
|
|||||||
Reference in New Issue
Block a user