first pass at dockerfile support

This commit is contained in:
Michael Hobbs
2015-02-07 10:47:04 -08:00
parent 122df4cdaf
commit 7357df7c9d
18 changed files with 292 additions and 68 deletions

View File

@@ -0,0 +1 @@
/ Hello World!

View File

@@ -0,0 +1,11 @@
FROM ubuntu:trusty
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
EXPOSE 5000
ADD . /app
RUN apt-get install -y software-properties-common && add-apt-repository ppa:chris-lea/node.js && apt-get update
RUN apt-get install -y build-essential curl postgresql-client-9.3 nodejs git
RUN cd /app && npm install
CMD cd /app && npm start

View File

@@ -0,0 +1,2 @@
#!/bin/bash
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!"

View File

@@ -0,0 +1,13 @@
var express = require('express')
var app = express();
app.set('port', (process.env.PORT || 5000))
app.use(express.static(__dirname + '/public'))
app.get('/', function(request, response) {
response.send('Hello World!')
})
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'))
})

View File

@@ -0,0 +1,29 @@
{
"name": "node-js-sample",
"version": "0.1.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.0.0"
},
"engines": {
"node": "0.10.x"
},
"repository": {
"type": "git",
"url": "https://github.com/heroku/node-js-sample"
},
"keywords": [
"node",
"heroku",
"express"
],
"author": "Mark Pundsack",
"contributors": [
"Zeke Sikelianos <zeke@sikelianos.com> (http://zeke.sikelianos.com)"
],
"license": "MIT"
}

0
tests/unit/apps.bats Executable file → Normal file
View File

View File

@@ -49,10 +49,18 @@ teardown() {
assert_output ""
}
@test "config (global)" {
@test "global config (buildstep)" {
deploy_app
run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "global config (dockerfile)" {
deploy_app dockerfile
run bash -c "docker inspect --format '{{ .Config.Env }}' $(< $DOKKU_ROOT/$TEST_APP/CONTAINER) | grep global_test"
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -10,7 +10,7 @@ teardown() {
destroy_app
}
# @test "ps" {
# @test "ps (buildstep)" {
# # CI support: 'Ah. I just spoke with our Docker expert --
# # looks like docker exec is built to work with docker-under-libcontainer,
# # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
@@ -21,7 +21,7 @@ teardown() {
# assert_success
# }
@test "ps:start" {
@test "ps:start (buildstep)" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -36,7 +36,7 @@ teardown() {
assert_success
}
@test "ps:stop" {
@test "ps:stop (buildstep)" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -47,7 +47,7 @@ teardown() {
assert_failure
}
@test "ps:restart" {
@test "ps:restart (buildstep)" {
run bash -c "dokku ps:restart $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -58,7 +58,7 @@ teardown() {
assert_success
}
@test "ps:rebuild" {
@test "ps:rebuild (buildstep)" {
run bash -c "dokku ps:rebuild $TEST_APP"
echo "output: "$output
echo "status: "$status

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env bats
load test_helper
setup() {
deploy_app dockerfile
}
teardown() {
destroy_app
}
@test "ps (dockerfile)" {
# CI support: 'Ah. I just spoke with our Docker expert --
# looks like docker exec is built to work with docker-under-libcontainer,
# but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
skip "circleci does not support docker exec at the moment."
run bash -c "dokku ps $TEST_APP | grep -q \"node web.js\""
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:start (dockerfile)" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:start $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:stop (dockerfile)" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_failure
}
@test "ps:restart (dockerfile)" {
run bash -c "dokku ps:restart $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:rebuild (dockerfile)" {
run bash -c "dokku ps:rebuild $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -93,8 +93,9 @@ destroy_app() {
}
deploy_app() {
APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"}
TMP=$(mktemp -d -t "$TARGET.XXXXX")
rmdir $TMP && cp -r ./tests/apps/nodejs-express $TMP
rmdir $TMP && cp -r ./tests/apps/$APP_TYPE $TMP
cd $TMP
git init
git config user.email "robot@example.com"