forked from TryGhost/node-sqlite3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <p.coval@samsung.com>
- Loading branch information
Showing
3 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
*~ | ||
Dockerfile | ||
.git/ | ||
tmp/ | ||
|
||
#{ [[./.gitignore]] | ||
# Standard artifacts | ||
*.swp | ||
.DS_Store | ||
.nyc_output/ | ||
.cache-loader/ | ||
|
||
# Build artifacts | ||
/build | ||
node_modules/ | ||
static/js/lib/stm_web.min.js | ||
|
||
# Run-time artifacts | ||
.node-persist/ | ||
config/local.js | ||
static/uploads | ||
.post_upgrade_complete | ||
/browser-test-output | ||
#} [[./.gitignore]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/echo docker build . -f | ||
# -*- coding: utf-8 -*- | ||
#{ | ||
# ISC License | ||
# Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") | ||
# Copyright (c) 1995-2003 by Internet Software Consortium | ||
# Permission to use, copy, modify, and /or distribute this software | ||
# for any purpose with or without fee is hereby granted, | ||
# provided that the above copyright notice | ||
# and this permission notice appear in all copies. | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | ||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | ||
# OF MERCHANTABILITY AND FITNESS. | ||
# IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, | ||
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | ||
# WHETHER IN AN ACTION OF CONTRACT, | ||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
# ARISING OUT OF OR IN CONNECTION WITH THE USE | ||
# OR PERFORMANCE OF THIS SOFTWARE. | ||
#} | ||
|
||
FROM ubuntu:latest | ||
MAINTAINER Philippe Coval (p.coval@samsung.com) | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV LC_ALL en_US.UTF-8 | ||
ENV LANG ${LC_ALL} | ||
|
||
RUN echo "#log: Configuring locales" \ | ||
&& set -x \ | ||
&& apt-get update -y \ | ||
&& apt-get install -y locales \ | ||
&& echo "${LC_ALL} UTF-8" | tee /etc/locale.gen \ | ||
&& locale-gen ${LC_ALL} \ | ||
&& dpkg-reconfigure locales \ | ||
&& sync | ||
|
||
ENV project node-sqlite3 | ||
|
||
RUN echo "#log: ${project}: Setup system" \ | ||
&& set -x \ | ||
&& apt-get update -y \ | ||
&& apt-get install -y \ | ||
curl \ | ||
sudo \ | ||
build-essential \ | ||
python \ | ||
&& apt-get clean \ | ||
&& NVM_VERSION="v0.33.8" \ | ||
&& NODE_VERSION="10" \ | ||
&& curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash \ | ||
&& which nvm || . ~/.bashrc \ | ||
&& nvm install ${NODE_VERSION} \ | ||
&& nvm use ${NODE_VERSION} \ | ||
&& sync | ||
|
||
ADD . /usr/local/${project}/${project} | ||
WORKDIR /usr/local/${project}/${project} | ||
RUN echo "#log: ${project}: Preparing sources" \ | ||
&& set -x \ | ||
&& which npm || . ~/.bashrc \ | ||
&& npm install || cat npm-debug.log \ | ||
&& npm install \ | ||
&& npm install --unsafe-perm --build-from-source \ | ||
&& npm run pak \ | ||
&& sync | ||
|
||
ADD . /usr/local/${project}/${project} | ||
WORKDIR /usr/local/${project}/${project} | ||
RUN echo "#log: ${project}: Preparing sources" \ | ||
&& set -x \ | ||
&& which npm || . ~/.bashrc \ | ||
&& npm run pak \ | ||
&& find build/stage/ -type f | ||
&& sync | ||
|
||
WORKDIR /usr/local/${project}/${project} | ||
RUN echo "#log: ${project}: Installing sources" \ | ||
&& set -x \ | ||
&& install -d /usr/local/src/${project}/ \ | ||
&& cp -rfva ./build/stage/ /usr/local/src/${project}/ \ | ||
&& sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
#!/bin/bash | ||
# -*- coding: utf-8 -*- | ||
#{ | ||
# ISC License | ||
# Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") | ||
# Copyright (c) 1995-2003 by Internet Software Consortium | ||
# Permission to use, copy, modify, and /or distribute this software | ||
# for any purpose with or without fee is hereby granted, | ||
# provided that the above copyright notice | ||
# and this permission notice appear in all copies. | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | ||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | ||
# OF MERCHANTABILITY AND FITNESS. | ||
# IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, | ||
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | ||
# WHETHER IN AN ACTION OF CONTRACT, | ||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
# ARISING OUT OF OR IN CONNECTION WITH THE USE | ||
# OR PERFORMANCE OF THIS SOFTWARE. | ||
#} | ||
|
||
set -e | ||
set -x | ||
|
||
env_() | ||
{ | ||
project="node-sqlite3" | ||
org="tizenteam" | ||
branch="master" | ||
url_suffix="#{branch}" | ||
|
||
# user="rzr" # Update here if forking | ||
# org="TizenTeam" | ||
# branch="sandbox/${user}/${branch}" | ||
# url_suffix="#{branch}" | ||
url_suffix="" # TODO: For older docker | ||
|
||
url="https://github.com/${org}/${project}.git${url_suffix}" | ||
run_url="https://raw.githubusercontent.com/${org}/${project}/${branch}/run.sh" | ||
|
||
release="0.0.0" | ||
src=false | ||
if [ -d '.git' ] && which git > /dev/null 2>&1 ; then | ||
src=true | ||
branch=$(git rev-parse --abbrev-ref HEAD) ||: | ||
release=$(git describe --tags || echo "$release") | ||
fi | ||
|
||
SELF="$0" | ||
[ "$SELF" != "$SHELL" ] || SELF="${PWD}/run.sh" | ||
[ "$SELF" != "/bin/bash" ] || SELF="${DASH_SOURCE}" | ||
[ "$SELF" != "/bin/bash" ] || SELF="${BASH_SOURCE}" | ||
self_basename=$(basename -- "${SELF}") | ||
} | ||
|
||
|
||
usage_() | ||
{ | ||
cat<<EOF | ||
Usage: | ||
$0 | ||
or | ||
curl -sL "${run_url}" | bash - | ||
EOF | ||
} | ||
|
||
|
||
die_() | ||
{ | ||
errno=$? | ||
echo "error: [$errno] $@" | ||
exit $errno | ||
} | ||
|
||
|
||
setup_debian_() | ||
{ | ||
which git || sudo apt-get install git | ||
which docker || sudo apt-get install docker.io | ||
|
||
sudo apt-get install qemu qemu-user-static binfmt-support | ||
sudo update-binfmts --enable qemu-arm | ||
} | ||
|
||
|
||
setup_() | ||
{ | ||
docker version && return $? ||: | ||
|
||
if [ -r /etc/debian_version ] ; then | ||
setup_debian_ | ||
else | ||
cat<<EOF | ||
warning: OS not supported | ||
Please ask for support at: | ||
${url} | ||
EOF | ||
cat /etc/os-release ||: | ||
fi | ||
|
||
docker version && return $? ||: | ||
docker --version || die_ "please install docker" | ||
groups | grep docker \ | ||
|| sudo addgroup ${USER} docker \ | ||
|| die_ "${USER} must be in docker group" | ||
su -l $USER -c "docker version" \ | ||
&& { su -l $USER -c "$SHELL $SELF $@" ; exit $?; } \ | ||
|| die_ "unexpected error" | ||
} | ||
|
||
|
||
prep_() | ||
{ | ||
echo "Prepare: " | ||
cat /etc/os-release | ||
docker version || setup_ | ||
} | ||
|
||
|
||
build_() | ||
{ | ||
version="latest" | ||
outdir="${PWD}/tmp/out" | ||
container="${project}" | ||
branch_name=$(echo "${branch}" | sed -e 's|/|.|g') | ||
dir="/usr/local/src/${project}/" | ||
image="${user}/${project}/${branch}" | ||
tag="$image:${version}" | ||
tag="${org}/${project}:${branch_name}" | ||
tag="${org}/${project}:${branch_name}.${release}" | ||
tag=$(echo "${tag}" | tr [A-Z] [a-z]) | ||
container="${project}" | ||
container=$(echo "${container}" | sed -e 's|/|-|g') | ||
if $src && [ "run.sh" = "${self_basename}" ] ; then | ||
docker build -t "${tag}" . | ||
else | ||
docker build -t "${tag}" "${url}" | ||
fi | ||
docker rm "${container}" > /dev/null 2>&1 ||: | ||
docker create --name "${container}" "${tag}" /bin/true | ||
rm -rf "${outdir}" | ||
mkdir -p "${outdir}" | ||
docker cp "${container}:${dir}" "${outdir}" | ||
echo "Check Ouput files in:" | ||
ls "${outdir}/"* | ||
find "${outdir}" -iname "*.tgz" | ||
} | ||
|
||
|
||
test_() | ||
{ | ||
curl -sL "${run_url}" | bash - | ||
} | ||
|
||
|
||
main_() | ||
{ | ||
env_ "$@" | ||
usage_ "$@" | ||
prep_ "$@" | ||
build_ "$@" | ||
} | ||
|
||
|
||
main_ "$@" |