-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.py
executable file
·52 lines (42 loc) · 1.27 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# activate build dsl
from nspawn.build import *
# define image url
import platform
epoch = "3.9"
release = f"{epoch}.4"
hardware = platform.machine()
image_url = f"file://localhost/tmp/nspawn/repo/alpine/base/default-{release}-{hardware}.tar.gz"
alpine_url = f"http://dl-cdn.alpinelinux.org/alpine/v{epoch}/releases/{hardware}/alpine-minirootfs-{release}-{hardware}.tar.gz"
# declare image identity
IMAGE(image_url)
# provision dependency image
PULL(alpine_url)
# termination for alpine /sbin/init (i.e. /bin/busybox)
WITH(KillSignal="SIGUSR1")
# copy local resources
COPY("/etc")
COPY("/root")
# template local resources
CAST("/root/readme.md", variable="template varialbe")
# invoke some bild program
RUN(["/usr/bin/env"])
# invoke build shell script
SH("apk update")
SH("apk upgrade")
SH("apk add tzdata")
SH("apk add ca-certificates")
SH("apk add busybox-initscripts")
SH("apk add mc htop pwgen")
SH("apk add iputils iproute2")
SH("apk add dhcpcd openssh ")
SH("rc-update add syslog")
SH("rc-update add dhcpcd")
SH("rc-update add sshd")
SH("""
echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config
user=root; pass=$(pwgen 64 1); echo $user:$pass | chpasswd
""")
# publish image to image url
PUSH()