mirror of
https://github.com/IS1DI/x0gp.git
synced 2026-07-16 20:47:55 +00:00
feat(server): add Dockerfile.fast and scripts for fast host-compiled builds
- Add Dockerfile.fast which packages a pre-built binary instead of compiling inside the container. - Add scripts/build-fast.ps1 (PowerShell) and scripts/build-fast.sh (Bash) to automate local cross-compilation (CGO_ENABLED=0 GOOS=linux) and Docker packaging. - Set executable bit for build-fast.sh.
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash script for fast Docker build using host compilation
|
||||
|
||||
set -e
|
||||
|
||||
ARCH=${1:-"arm64"}
|
||||
TAG=${2:-"x0gp-server:latest"}
|
||||
|
||||
# Navigate to the server root directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVER_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
cd "$SERVER_DIR"
|
||||
|
||||
echo "Building Go binary for OS=linux, ARCH=${ARCH}..."
|
||||
mkdir -p bin
|
||||
BIN_PATH="bin/poc-server-linux-${ARCH}"
|
||||
|
||||
# Compile locally
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags="-s -w" -o "${BIN_PATH}" ./cmd/poc-server
|
||||
|
||||
echo "Go binary successfully compiled: ${BIN_PATH}"
|
||||
echo "Building Docker image '${TAG}'..."
|
||||
|
||||
# Build docker image
|
||||
docker build --build-arg BINARY_PATH="${BIN_PATH}" -t "${TAG}" -f Dockerfile.fast .
|
||||
|
||||
echo -e "\nDocker image '${TAG}' built successfully!"
|
||||
Reference in New Issue
Block a user