mirror of
https://github.com/openstf/stf
synced 2025-10-06 12:00:08 +02:00
Get rid of our internal "build system" and switch to a CI-buildable Dockerfile instead.
This commit is contained in:
parent
f726c0a614
commit
775bffe4a9
19 changed files with 43 additions and 367 deletions
14
.dockerignore
Normal file
14
.dockerignore
Normal file
|
@ -0,0 +1,14 @@
|
|||
*.mo
|
||||
*.tgz
|
||||
.DS_Store
|
||||
.env
|
||||
.git/
|
||||
.idea/
|
||||
Dockerfile
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
res/bower_components/
|
||||
res/build/
|
||||
rethinkdb_data/
|
||||
temp/
|
||||
tmp/
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,7 +3,6 @@
|
|||
.idea/
|
||||
/*.tgz
|
||||
/.env
|
||||
/.heroku/
|
||||
/doc/*.png
|
||||
/node_modules/
|
||||
/res/bower_components/
|
||||
|
|
|
@ -5,14 +5,12 @@
|
|||
/.editorconfig
|
||||
/.env
|
||||
/.gitignore
|
||||
/.heroku/
|
||||
/.idea/
|
||||
/.jscsrc
|
||||
/.npmignore
|
||||
/.npmrc
|
||||
/Dockerfile
|
||||
/bower.json
|
||||
/buildpack/
|
||||
/component.json
|
||||
/doc/
|
||||
/gulpfile.js
|
||||
|
|
29
Dockerfile
29
Dockerfile
|
@ -1,12 +1,41 @@
|
|||
FROM sorccu/node:0.12.2
|
||||
MAINTAINER Simo Kinnunen
|
||||
|
||||
# Install requirements.
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||
apt-get update && \
|
||||
apt-get -y install libzmq3-dev libprotobuf-dev git graphicsmagick && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/cache/apt/*
|
||||
|
||||
# Add a user for the app.
|
||||
RUN useradd --system \
|
||||
--no-create-home \
|
||||
--shell /usr/sbin/nologin \
|
||||
--home-dir /app \
|
||||
stf
|
||||
|
||||
# Sneak the stf executable into $PATH.
|
||||
ENV PATH /app/bin:$PATH
|
||||
|
||||
# Work in app dir by default.
|
||||
WORKDIR /app
|
||||
|
||||
# Export default app port, not enough for all processes but it should do
|
||||
# for now.
|
||||
EXPOSE 3000
|
||||
|
||||
# Copy app source.
|
||||
COPY . /app/
|
||||
|
||||
# Get the rest of the dependencies and build.
|
||||
RUN export PATH=/app/node_modules/.bin:$PATH && \
|
||||
npm install && \
|
||||
bower install --allow-root && \
|
||||
gulp build
|
||||
|
||||
# Switch to weak user.
|
||||
USER stf
|
||||
|
||||
# Show help by default.
|
||||
CMD stf --help
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error() {
|
||||
echo " ! $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
echo "-----> $*"
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # fail fast
|
||||
set -o pipefail # don't ignore exit codes when piping output
|
||||
# set -x # enable debugging
|
||||
|
||||
bp_dir=$(cd $(dirname $0); cd ..; pwd)
|
||||
|
||||
# Load some convenience functions like status()
|
||||
source $bp_dir/bin/common.sh
|
||||
|
||||
for pack in node bower gulp; do
|
||||
if name=$($bp_dir/buildpacks/$pack/bin/detect "$@"); then
|
||||
if test -f $bp_dir/buildpacks/$pack/bin/compact; then
|
||||
status "Compacting ${name}"
|
||||
$bp_dir/buildpacks/$pack/bin/compact "$@"
|
||||
fi
|
||||
fi
|
||||
done
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # fail fast
|
||||
set -o pipefail # don't ignore exit codes when piping output
|
||||
# set -x # enable debugging
|
||||
|
||||
bp_dir=$(cd $(dirname $0); cd ..; pwd)
|
||||
|
||||
# Load some convenience functions like status()
|
||||
source $bp_dir/bin/common.sh
|
||||
|
||||
for pack in node bower gulp; do
|
||||
if name=$($bp_dir/buildpacks/$pack/bin/detect "$@"); then
|
||||
status "Detected ${name}"
|
||||
$bp_dir/buildpacks/$pack/bin/compile "$@"
|
||||
fi
|
||||
done
|
|
@ -1,26 +0,0 @@
|
|||
error() {
|
||||
echo " ! $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
echo "-----> $*"
|
||||
}
|
||||
|
||||
protip() {
|
||||
echo
|
||||
echo "PRO TIP: $*" | indent
|
||||
echo "See https://devcenter.heroku.com/articles/nodejs-support" | indent
|
||||
echo
|
||||
}
|
||||
|
||||
# sed -l basically makes sed replace and buffer through stdin to stdout
|
||||
# so you get updates while the command runs and dont wait for the end
|
||||
# e.g. npm install | indent
|
||||
indent() {
|
||||
c='s/^/ /'
|
||||
case $(uname) in
|
||||
Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
|
||||
*) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
|
||||
esac
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # fail fast
|
||||
set -o pipefail # don't ignore exit codes when piping output
|
||||
# set -x # enable debugging
|
||||
|
||||
# Configure directories
|
||||
build_dir=$1
|
||||
cache_dir=$2
|
||||
env_dir=$3
|
||||
|
||||
bp_dir=$(cd $(dirname $0); cd ..; pwd)
|
||||
|
||||
# Load some convenience functions like status() and indent()
|
||||
source $bp_dir/bin/common.sh
|
||||
|
||||
# Expose user-installed bower
|
||||
export PATH=$build_dir/node_modules/.bin:$PATH
|
||||
|
||||
# Get bower version
|
||||
bower_bin=$(which bower)
|
||||
bower_version=$(bower --version)
|
||||
status "Using Bower $bower_version from ${bower_bin#$build_dir/}"
|
||||
|
||||
# Run subsequent node/bower commands from the build path
|
||||
cd $build_dir
|
||||
|
||||
# Figure out where Bower should install the components
|
||||
bower_install=$(node -pe 'JSON.parse(require("fs").readFileSync(process.argv[1])).directory || "bower_components"' .bowerrc)
|
||||
|
||||
# If the bower installation directory is checked into source control
|
||||
# then assume that we are not supposed to touch it. Otherwise, restore
|
||||
# from the build cache.
|
||||
if test -d $build_dir/$bower_install; then
|
||||
status "Found existing $bower_install directory; skipping cache"
|
||||
elif test -d $cache_dir/bower/install; then
|
||||
status "Restoring $bower_install directory from cache"
|
||||
cp -r $cache_dir/bower/install $build_dir/$bower_install
|
||||
|
||||
status "Pruning cached dependencies not specified in bower.json"
|
||||
bower --allow-root --config.cwd=$build_dir prune 2>&1 | indent
|
||||
fi
|
||||
|
||||
status "Installing bower dependencies"
|
||||
bower --allow-root --config.cwd=$build_dir --config.storage.packages=$cache_dir/bower/packages --config.storage.registry=$cache_dir/bower/registry install 2>&1 | indent
|
||||
|
||||
# Purge bower-related cached content, being careful not to purge the top-level
|
||||
# cache, for the sake of heroku-buildpack-multi apps.
|
||||
rm -rf $cache_dir/bower
|
||||
mkdir -p $cache_dir/bower
|
||||
|
||||
# If app has a node_modules directory, cache it.
|
||||
if test -d $build_dir/$bower_install; then
|
||||
status "Caching $bower_install directory for future builds"
|
||||
cp -r $build_dir/$bower_install $cache_dir/bower/install/
|
||||
fi
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# bin/detect <build-dir>
|
||||
|
||||
if [ -f $1/.bowerrc ]; then
|
||||
echo "Bower" && exit 0
|
||||
else
|
||||
echo "no" && exit 1
|
||||
fi
|
|
@ -1,26 +0,0 @@
|
|||
error() {
|
||||
echo " ! $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
echo "-----> $*"
|
||||
}
|
||||
|
||||
protip() {
|
||||
echo
|
||||
echo "PRO TIP: $*" | indent
|
||||
echo "See https://devcenter.heroku.com/articles/nodejs-support" | indent
|
||||
echo
|
||||
}
|
||||
|
||||
# sed -l basically makes sed replace and buffer through stdin to stdout
|
||||
# so you get updates while the command runs and dont wait for the end
|
||||
# e.g. npm install | indent
|
||||
indent() {
|
||||
c='s/^/ /'
|
||||
case $(uname) in
|
||||
Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
|
||||
*) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
|
||||
esac
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # fail fast
|
||||
set -o pipefail # don't ignore exit codes when piping output
|
||||
# set -x # enable debugging
|
||||
|
||||
# Configure directories
|
||||
build_dir=$1
|
||||
cache_dir=$2
|
||||
env_dir=$3
|
||||
|
||||
bp_dir=$(cd $(dirname $0); cd ..; pwd)
|
||||
|
||||
# Load some convenience functions like status() and indent()
|
||||
source $bp_dir/bin/common.sh
|
||||
|
||||
# Expose user-installed bower
|
||||
export PATH=$build_dir/node_modules/.bin:$PATH
|
||||
|
||||
# Get gulp version
|
||||
gulp_bin=$(which gulp)
|
||||
status "Using Gulp from ${gulp_bin#$build_dir/}"
|
||||
gulp -v 2>&1 | indent
|
||||
|
||||
# Run subsequent node/gulp commands from the build path
|
||||
cd $build_dir
|
||||
|
||||
status "Building"
|
||||
gulp build 2>&1 | indent
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# bin/detect <build-dir>
|
||||
|
||||
if [ -f $1/gulpfile.js ]; then
|
||||
echo "Gulp" && exit 0
|
||||
else
|
||||
echo "no" && exit 1
|
||||
fi
|
|
@ -1 +0,0 @@
|
|||
This buildpack is based on [heroku-buildpack-nodejs](https://github.com/heroku/heroku-buildpack-nodejs).
|
|
@ -1,38 +0,0 @@
|
|||
error() {
|
||||
echo " ! $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
echo "-----> $*"
|
||||
}
|
||||
|
||||
protip() {
|
||||
echo
|
||||
echo "PRO TIP: $*" | indent
|
||||
echo "See https://devcenter.heroku.com/articles/nodejs-support" | indent
|
||||
echo
|
||||
}
|
||||
|
||||
# sed -l basically makes sed replace and buffer through stdin to stdout
|
||||
# so you get updates while the command runs and dont wait for the end
|
||||
# e.g. npm install | indent
|
||||
indent() {
|
||||
c='s/^/ /'
|
||||
case $(uname) in
|
||||
Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
|
||||
*) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
|
||||
esac
|
||||
}
|
||||
|
||||
cat_npm_debug_log() {
|
||||
test -f $build_dir/npm-debug.log && cat $build_dir/npm-debug.log
|
||||
}
|
||||
|
||||
cp_keep_links() {
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
cp -p "$@"
|
||||
else
|
||||
cp --preserve=links "$@"
|
||||
fi
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # fail fast
|
||||
set -o pipefail # don't ignore exit codes when piping output
|
||||
# set -x # enable debugging
|
||||
|
||||
# Configure directories
|
||||
build_dir=$1
|
||||
cache_dir=$2
|
||||
env_dir=$3
|
||||
|
||||
bp_dir=$(cd $(dirname $0); cd ..; pwd)
|
||||
|
||||
# Load some convenience functions like status() and indent()
|
||||
source $bp_dir/bin/common.sh
|
||||
|
||||
# Output npm debug info on error
|
||||
trap cat_npm_debug_log ERR
|
||||
|
||||
# Run subsequent node/npm commands from the build path
|
||||
cd $build_dir
|
||||
|
||||
# Run twice as we may be able to remove a few more dependencies
|
||||
# on the second run
|
||||
status "Pruning development dependencies"
|
||||
npm prune --production --userconfig $build_dir/.npmrc 2>&1 | indent
|
||||
npm prune --production --userconfig $build_dir/.npmrc 2>&1 | indent
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # fail fast
|
||||
set -o pipefail # don't ignore exit codes when piping output
|
||||
# set -x # enable debugging
|
||||
|
||||
# Configure directories
|
||||
build_dir=$1
|
||||
cache_dir=$2
|
||||
env_dir=$3
|
||||
|
||||
bp_dir=$(cd $(dirname $0); cd ..; pwd)
|
||||
|
||||
# Load some convenience functions like status() and indent()
|
||||
source $bp_dir/bin/common.sh
|
||||
|
||||
# Output npm debug info on error
|
||||
trap cat_npm_debug_log ERR
|
||||
|
||||
# Get node version
|
||||
node_version=$(node --version)
|
||||
status "Using Node.js $node_version"
|
||||
|
||||
# Run subsequent node/npm commands from the build path
|
||||
cd $build_dir
|
||||
|
||||
install() {
|
||||
(
|
||||
# Scope config var availability only to `npm install`
|
||||
if [ -d "$env_dir" ]; then
|
||||
status "Exporting config vars to environment"
|
||||
export_env_dir $env_dir
|
||||
fi
|
||||
|
||||
status "Installing npm dependencies"
|
||||
# Make npm output to STDOUT instead of its default STDERR
|
||||
npm install --loglevel=http --userconfig $build_dir/.npmrc "$@" 2>&1 | indent
|
||||
)
|
||||
}
|
||||
|
||||
# If node_modules directory is checked into source control then
|
||||
# rebuild any native deps. Otherwise, restore from the build cache.
|
||||
if test -d $build_dir/node_modules; then
|
||||
status "Found existing node_modules directory; skipping cache"
|
||||
# Attempt to work around npm/npm#5400
|
||||
install --ignore-scripts
|
||||
status "Rebuilding any native dependencies to work around npm/npm#5400"
|
||||
npm rebuild 2>&1 | indent
|
||||
elif test -d $cache_dir/node/node_modules; then
|
||||
status "Restoring node_modules directory from cache"
|
||||
cp_keep_links -R $cache_dir/node/node_modules $build_dir/
|
||||
|
||||
status "Pruning cached dependencies not specified in package.json"
|
||||
npm prune 2>&1 | indent
|
||||
|
||||
if test -f $cache_dir/node/.heroku/node-version && [ $(cat $cache_dir/node/.heroku/node-version) != "$node_version" ]; then
|
||||
status "Node version changed since last build; rebuilding dependencies"
|
||||
npm rebuild 2>&1 | indent
|
||||
fi
|
||||
|
||||
# Let's hope that npm/npm#5400 only hits us on the first run
|
||||
install
|
||||
else
|
||||
# Attempt to work around npm/npm#5400
|
||||
install --ignore-scripts
|
||||
status "Rebuilding any native dependencies to work around npm/npm#5400"
|
||||
npm rebuild 2>&1 | indent
|
||||
fi
|
||||
|
||||
# Persist goodies like node-version in the slug
|
||||
mkdir -p $build_dir/.heroku
|
||||
|
||||
# Save resolved node version in the slug for later reference
|
||||
echo $node_version > $build_dir/.heroku/node-version
|
||||
|
||||
# Purge node-related cached content, being careful not to purge the top-level
|
||||
# cache, for the sake of heroku-buildpack-multi apps.
|
||||
rm -rf $cache_dir/node
|
||||
mkdir -p $cache_dir/node
|
||||
|
||||
# If app has a node_modules directory, cache it.
|
||||
if test -d $build_dir/node_modules; then
|
||||
status "Caching node_modules directory for future builds"
|
||||
cp_keep_links -R $build_dir/node_modules $cache_dir/node
|
||||
fi
|
||||
|
||||
# Copy goodies to the cache
|
||||
cp -r $build_dir/.heroku $cache_dir/node
|
||||
|
||||
status "Cleaning up node-gyp and npm artifacts"
|
||||
rm -rf "$build_dir/.node-gyp"
|
||||
rm -rf "$build_dir/.npm"
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# bin/detect <build-dir>
|
||||
|
||||
if [ -f $1/package.json ]; then
|
||||
echo "Node.js" && exit 0
|
||||
else
|
||||
echo "no" && exit 1
|
||||
fi
|
|
@ -1 +0,0 @@
|
|||
sorccu/node:0.10
|
Loading…
Add table
Add a link
Reference in a new issue