-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·54 lines (40 loc) · 918 Bytes
/
build.sh
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
53
54
#!/usr/bin/env bash
#
# Download and build nodejs container
set -euo pipefail
src=${PWD}/src
out=${PWD}/out
rootfs=${PWD}/rootfs
_download() {
mkdir -p ${rootfs}
curl -sL 'https://github.com/gliderlabs/docker-alpine/blob/rootfs/library-edge/versions/library-edge/rootfs.tar.gz?raw=true' | \
tar -C ${rootfs} -zxf -
}
_build() {
mv ${rootfs}/etc/localtime ${rootfs}/usr/share/zoneinfo
ln -s /usr/share/zoneinfo ${rootfs}/etc/localtime
cat <<EOF > ${rootfs}/etc/passwd
root:x:0:0:root:/:/dev/null
nobody:x:65534:65534:nogroup:/:/dev/null
EOF
cat <<EOF > ${rootfs}/etc/group
root:x:0:
nogroup:x:65534:
EOF
tar -cf ${out}/rootfs.tar -C ${rootfs} .
}
# _dockerfile "version"
_dockerfile() {
cat <<EOF > ${out}/version
${1}
EOF
cat <<EOF > ${out}/Dockerfile
FROM scratch
ADD rootfs.tar /
ENV NODE_ENV=production
RUN apk add --no-cache nodejs
EOF
}
_download
_build
_dockerfile next