Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build for other os/arch #469

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,91 @@ jobs:
with:
path: stacker
key: ${{ inputs.build-id }}
build-arch:
runs-on: ubuntu-22.04
services:
registry:
image: registry:2
ports:
- 5000:5000
strategy:
matrix:
go-version: ${{fromJson(inputs.go-version)}}
privilege-level: ${{fromJson(inputs.privilege-level)}}
arch: ["arm64"]
name: "golang ${{ matrix.go-version }} privilege ${{ matrix.privilege-level }} arch ${{ matrix.arch }}"
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
- name: Setup Environment
run: |
gopath=$PWD/.build/gopath
echo "GOPATH=$gopath" >> $GITHUB_ENV
echo "GOCACHE=$gopath/gocache" >> $GITHUB_ENV
echo "PATH=$gopath/bin:$PATH" >> $GITHUB_ENV
echo "SLOW_TEST=${{inputs.slow-test}}" >> $GITHUB_ENV
if [ "${{ matrix.arch }}" == "arm64" ]; then
echo "QEMU_ARCH=aarch64" >> $GITHUB_ENV
echo "BASE_IMAGE=docker://arm64v8/alpine:edge" >> $GITHUB_ENV
fi

echo "PWD=$PWD"
cat "$GITHUB_ENV"
- uses: uraimo/run-on-arch-action@v2
name: Build for ${{ matrix.arch }}
id: runcmd
with:
arch: ${{ env.QEMU_ARCH }}
distro: ubuntu22.04

# Not required, but speeds up builds by storing container images in
# a GitHub package registry.
githubToken: ${{ github.token }}

dockerRunArgs: -v $GITHUB_WORKSPACE:/src

# Set an output parameter `uname` for use in subsequent steps
run: |
uname -a
echo ::set-output name=uname::$(uname -a)
# setup golang
apt-get update
apt-get install -yy wget curl tar software-properties-common git pkgconf build-essential
cd /tmp
wget -N https://go.dev/dl/go1.20.8.linux-${{ matrix.arch }}.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.8.linux-${{ matrix.arch }}.tar.gz
export PATH=$PATH:/usr/local/go/bin
# install dependencies
export GOPATH=/src
add-apt-repository -y ppa:project-machine/squashfuse
apt-get update
apt-get install -yy lxc-utils lxc-dev libacl1-dev jq libcap-dev libseccomp-dev libpam-dev bats parallel libzstd-dev sudo
GO111MODULE=off go get github.com/opencontainers/umoci/cmd/umoci
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
apt-get install -yy autoconf automake make autogen autoconf libtool binutils git squashfs-tools libcryptsetup-dev libdevmapper-dev cryptsetup-bin squashfuse
echo WHOAMI=$(whoami)

# add a non-root user "stacker"
adduser --disabled-login --no-create-home --gecos "stacker" stacker

mkdir /src-copy
cp -R /src/* /src-copy/
chown -R stacker:stacker /src-copy

# execute this as "stacker" user
sudo -i -u stacker bash << EOF
echo WHOAMI=$(whoami)
export PATH=$PATH:/usr/local/go/bin
cd /src-copy
make go-download
make show-info
make stacker-dynamic VERSION_FULL=${{ inputs.build-id }}
export QEMU_STRACE=1
make stacker STACKER_REAL_UID=0 VERSION_FULL=${{ inputs.build-id }} STACKER_BUILD_BASE_IMAGE=${{ env.BASE_IMAGE }}
EOF
- name: Get the output
# Echo the `uname` output parameter from the `runcmd` step
run: |
echo "The uname output was ${{ steps.runcmd.outputs.uname }}"

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BUILD_TAGS = exclude_graphdriver_btrfs exclude_graphdriver_devicemapper containe

STACKER_OPTS=--oci-dir=$(BUILD_D)/oci --roots-dir=$(BUILD_D)/roots --stacker-dir=$(BUILD_D)/stacker --storage-type=overlay

build_stacker = go build -tags "$(BUILD_TAGS) $1" -ldflags "-X main.version=$(VERSION_FULL) -X main.lxc_version=$(LXC_VERSION) $2" -o $3 ./cmd/stacker
build_stacker = go build -buildvcs=false -tags "$(BUILD_TAGS) $1" -ldflags "-X main.version=$(VERSION_FULL) -X main.lxc_version=$(LXC_VERSION) $2" -o $3 ./cmd/stacker

# See doc/hacking.md for how to use a local oci or docker repository.
STACKER_DOCKER_BASE?=docker://
Expand Down
2 changes: 1 addition & 1 deletion cmd/stacker/lxc-wrapper/lxc-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static int do_nsexec(char* mode, int argc, char *argv[], int *status)
pid_t pid;
int ret, cur, group_start = -1, command_start = -1;
char c = 'x', thepid[20];
static char child_stack[STACK_SIZE];
static char child_stack[STACK_SIZE] __attribute__ ((aligned (16)));
struct child_args args;

// userns - should a userns be used?
Expand Down