Skip to content

Commit d201ce5

Browse files
committed
build: Support docker to build binary package
Usage: curl -sL https://rawgit.com/$org/$project/$branch/run.sh | bash -x - ls tmp/out/node-sqlite3/sqlite3-*.tgz Or run.sh can be run in sources Change-Id: I79000463955d16eec8809c870f7d02c60da53432 Bug: TryGhost#418 Forwarded: TryGhost#1028 Origin: https://github.com/tizenteam/node-sqlite3 Signed-off-by: Philippe Coval <[email protected]>
1 parent d6f0944 commit d201ce5

File tree

3 files changed

+275
-0
lines changed

3 files changed

+275
-0
lines changed

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*~
2+
Dockerfile
3+
.git/
4+
tmp/
5+
6+
#{ [[./.gitignore]]
7+
# Standard artifacts
8+
*.swp
9+
.DS_Store
10+
.nyc_output/
11+
.cache-loader/
12+
13+
# Build artifacts
14+
/build
15+
node_modules/
16+
static/js/lib/stm_web.min.js
17+
18+
# Run-time artifacts
19+
.node-persist/
20+
config/local.js
21+
static/uploads
22+
.post_upgrade_complete
23+
/browser-test-output
24+
#} [[./.gitignore]]

Dockerfile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/echo docker build . -f
2+
# -*- coding: utf-8 -*-
3+
#{
4+
# ISC License
5+
# Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
6+
# Copyright (c) 1995-2003 by Internet Software Consortium
7+
# Permission to use, copy, modify, and /or distribute this software
8+
# for any purpose with or without fee is hereby granted,
9+
# provided that the above copyright notice
10+
# and this permission notice appear in all copies.
11+
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
12+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
13+
# OF MERCHANTABILITY AND FITNESS.
14+
# IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
15+
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17+
# WHETHER IN AN ACTION OF CONTRACT,
18+
# NEGLIGENCE OR OTHER TORTIOUS ACTION,
19+
# ARISING OUT OF OR IN CONNECTION WITH THE USE
20+
# OR PERFORMANCE OF THIS SOFTWARE.
21+
#}
22+
23+
FROM ubuntu:latest
24+
MAINTAINER Philippe Coval ([email protected])
25+
26+
ENV DEBIAN_FRONTEND noninteractive
27+
ENV LC_ALL en_US.UTF-8
28+
ENV LANG ${LC_ALL}
29+
30+
RUN echo "#log: Configuring locales" \
31+
&& set -x \
32+
&& apt-get update -y \
33+
&& apt-get install -y locales \
34+
&& echo "${LC_ALL} UTF-8" | tee /etc/locale.gen \
35+
&& locale-gen ${LC_ALL} \
36+
&& dpkg-reconfigure locales \
37+
&& sync
38+
39+
ENV project node-sqlite3
40+
41+
RUN echo "#log: ${project}: Setup system" \
42+
&& set -x \
43+
&& apt-get update -y \
44+
&& apt-get install -y \
45+
curl \
46+
sudo \
47+
build-essential \
48+
python \
49+
&& apt-get clean \
50+
&& NVM_VERSION="v0.33.8" \
51+
&& NODE_VERSION="10" \
52+
&& curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash \
53+
&& which nvm || . ~/.bashrc \
54+
&& nvm install ${NODE_VERSION} \
55+
&& nvm use ${NODE_VERSION} \
56+
&& sync
57+
58+
ADD . /usr/local/${project}/${project}
59+
WORKDIR /usr/local/${project}/${project}
60+
RUN echo "#log: ${project}: Preparing sources" \
61+
&& set -x \
62+
&& which npm || . ~/.bashrc \
63+
&& npm install || cat npm-debug.log \
64+
&& npm install \
65+
&& npm install --unsafe-perm --build-from-source \
66+
&& npm run pak \
67+
&& sync
68+
69+
ADD . /usr/local/${project}/${project}
70+
WORKDIR /usr/local/${project}/${project}
71+
RUN echo "#log: ${project}: Preparing sources" \
72+
&& set -x \
73+
&& which npm || . ~/.bashrc \
74+
&& npm run pak \
75+
&& find build/stage \
76+
&& tar tvf ./build/stage/sqlite3/v4.0.2/node-v64-linux-x64.tar.gz \
77+
&& sync
78+
79+
WORKDIR /usr/local/${project}/${project}
80+
RUN echo "#log: ${project}: Installing sources" \
81+
&& set -x \
82+
&& install -d /usr/local/src/${project}/ \
83+
&& cp -rfva ./build/stage/ /usr/local/src/${project}/ \
84+
&& sync

run.sh

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/bin/bash
2+
# -*- coding: utf-8 -*-
3+
#{
4+
# ISC License
5+
# Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
6+
# Copyright (c) 1995-2003 by Internet Software Consortium
7+
# Permission to use, copy, modify, and /or distribute this software
8+
# for any purpose with or without fee is hereby granted,
9+
# provided that the above copyright notice
10+
# and this permission notice appear in all copies.
11+
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
12+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
13+
# OF MERCHANTABILITY AND FITNESS.
14+
# IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
15+
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17+
# WHETHER IN AN ACTION OF CONTRACT,
18+
# NEGLIGENCE OR OTHER TORTIOUS ACTION,
19+
# ARISING OUT OF OR IN CONNECTION WITH THE USE
20+
# OR PERFORMANCE OF THIS SOFTWARE.
21+
#}
22+
23+
set -e
24+
set -x
25+
26+
env_()
27+
{
28+
project="node-sqlite3"
29+
org="tizenteam"
30+
branch="master"
31+
url_suffix="#{branch}"
32+
33+
# user="rzr" # Update here if forking
34+
# org="TizenTeam"
35+
# branch="sandbox/${user}/${branch}"
36+
# url_suffix="#{branch}"
37+
url_suffix="" # TODO: For older docker
38+
39+
url="https://github.com/${org}/${project}.git${url_suffix}"
40+
run_url="https://raw.githubusercontent.com/${org}/${project}/${branch}/run.sh"
41+
42+
release="0.0.0"
43+
src=false
44+
if [ -d '.git' ] && which git > /dev/null 2>&1 ; then
45+
src=true
46+
branch=$(git rev-parse --abbrev-ref HEAD) ||:
47+
release=$(git describe --tags || echo "$release")
48+
fi
49+
50+
SELF="$0"
51+
[ "$SELF" != "$SHELL" ] || SELF="${PWD}/run.sh"
52+
[ "$SELF" != "/bin/bash" ] || SELF="${DASH_SOURCE}"
53+
[ "$SELF" != "/bin/bash" ] || SELF="${BASH_SOURCE}"
54+
self_basename=$(basename -- "${SELF}")
55+
}
56+
57+
58+
usage_()
59+
{
60+
cat<<EOF
61+
Usage:
62+
$0
63+
or
64+
curl -sL "${run_url}" | bash -
65+
66+
EOF
67+
}
68+
69+
70+
die_()
71+
{
72+
errno=$?
73+
echo "error: [$errno] $@"
74+
exit $errno
75+
}
76+
77+
78+
setup_debian_()
79+
{
80+
which git || sudo apt-get install git
81+
which docker || sudo apt-get install docker.io
82+
83+
sudo apt-get install qemu qemu-user-static binfmt-support
84+
sudo update-binfmts --enable qemu-arm
85+
}
86+
87+
88+
setup_()
89+
{
90+
docker version && return $? ||:
91+
92+
if [ -r /etc/debian_version ] ; then
93+
setup_debian_
94+
else
95+
cat<<EOF
96+
warning: OS not supported
97+
Please ask for support at:
98+
${url}
99+
EOF
100+
cat /etc/os-release ||:
101+
fi
102+
103+
docker version && return $? ||:
104+
docker --version || die_ "please install docker"
105+
groups | grep docker \
106+
|| sudo addgroup ${USER} docker \
107+
|| die_ "${USER} must be in docker group"
108+
su -l $USER -c "docker version" \
109+
&& { su -l $USER -c "$SHELL $SELF $@" ; exit $?; } \
110+
|| die_ "unexpected error"
111+
}
112+
113+
114+
prep_()
115+
{
116+
echo "Prepare: "
117+
cat /etc/os-release
118+
docker version || setup_
119+
}
120+
121+
122+
build_()
123+
{
124+
version="latest"
125+
outdir="${PWD}/tmp/out"
126+
container="${project}"
127+
branch_name=$(echo "${branch}" | sed -e 's|/|.|g')
128+
dir="/usr/local/src/${project}/"
129+
image="${user}/${project}/${branch}"
130+
tag="$image:${version}"
131+
tag="${org}/${project}:${branch_name}"
132+
tag="${org}/${project}:${branch_name}.${release}"
133+
tag=$(echo "${tag}" | tr [A-Z] [a-z])
134+
container="${project}"
135+
container=$(echo "${container}" | sed -e 's|/|-|g')
136+
if $src && [ "run.sh" = "${self_basename}" ] ; then
137+
docker build -t "${tag}" .
138+
else
139+
docker build -t "${tag}" "${url}"
140+
fi
141+
docker rm "${container}" > /dev/null 2>&1 ||:
142+
docker create --name "${container}" "${tag}" /bin/true
143+
rm -rf "${outdir}"
144+
mkdir -p "${outdir}"
145+
docker cp "${container}:${dir}" "${outdir}"
146+
echo "Check Ouput files in:"
147+
ls "${outdir}/"*
148+
find "${outdir}" -iname "*.tgz"
149+
}
150+
151+
152+
test_()
153+
{
154+
curl -sL "${run_url}" | bash -
155+
}
156+
157+
158+
main_()
159+
{
160+
env_ "$@"
161+
usage_ "$@"
162+
prep_ "$@"
163+
build_ "$@"
164+
}
165+
166+
167+
main_ "$@"

0 commit comments

Comments
 (0)