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

Draft: LXC support for self-hosted runners #1682

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
install node 16 & git for checkout to work
  • Loading branch information
earl-warren committed Mar 16, 2023
commit 2ccb31234669f458fa5b70e737f6a3601033d130
22 changes: 18 additions & 4 deletions pkg/runner/run_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ mount --bind {{ .Root }} /var/lib/lxc/{{.Name}}/rootfs/{{ .Root }}
mkdir /var/lib/lxc/{{.Name}}/rootfs/tmpdir
mount --bind {{.TmpDir}} /var/lib/lxc/{{.Name}}/rootfs/tmpdir

lxc-start {{.Name}}
lxc-wait --name {{.Name}} --state RUNNING

#
# Wait for the network to come up
#
cat > /var/lib/lxc/{{.Name}}/rootfs/tmpdir/networking.sh <<'EOF'
#!/bin/sh -xe
for d in $(seq 60); do
Expand All @@ -191,11 +197,19 @@ getent hosts wikipedia.org
EOF
chmod +x /var/lib/lxc/{{.Name}}/rootfs/tmpdir/networking.sh

lxc-start {{.Name}}
lxc-wait --name {{.Name}} --state RUNNING
lxc-attach --name {{.Name}} -- /tmpdir/networking.sh
exit 0
lxc-attach --name {{.Name}} -- /bin/sh -c 'cd "/woodpecker/{{ .Repo }}" && /bin/sh -ex /rundir/{{ .Script }}'

cat > /var/lib/lxc/{{.Name}}/rootfs/tmpdir/node.sh <<'EOF'
#!/bin/sh -xe
# https://github.com/nodesource/distributions#debinstall
apt-get install -y curl git
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs
EOF
chmod +x /var/lib/lxc/{{.Name}}/rootfs/tmpdir/node.sh

lxc-attach --name {{.Name}} -- /tmpdir/node.sh

`))

var stopTemplate = template.Must(template.New("stop").Parse(`#!/bin/sh -x
Expand Down