Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-static
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-static
Commits
cf80709c
Commit
cf80709c
authored
Jun 02, 2015
by
Terence Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extract the buildpack into its own image
parent
d0ea6f40
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
30 deletions
+58
-30
Dockerfile
Dockerfile
+17
-0
Dockerfile
spec/fixtures/hello_world/Dockerfile
+1
-16
simple_spec.rb
spec/simple_spec.rb
+7
-4
app_runner.rb
spec/support/app_runner.rb
+4
-10
buildpack_builder.rb
spec/support/buildpack_builder.rb
+29
-0
No files found.
Dockerfile
0 → 100644
View file @
cf80709c
FROM
heroku/cedar:14
RUN
useradd
-d
/app
-m
app
USER
app
WORKDIR
/buildpack
COPY
bin/ /buildpack/bin/
COPY
scripts/ /buildpack/scripts/
RUN
/buildpack/bin/compile /app
ENV
HOME /app
ENV
PORT 3000
EXPOSE
3000
ONBUILD
WORKDIR
/app/
ONBUILD
COPY
. /app/
ONBUILD
CMD
/app/bin/boot
spec/fixtures/hello_world/Dockerfile
View file @
cf80709c
FROM
heroku/cedar:14
RUN
useradd
-d
/app
-m
app
USER
app
WORKDIR
/app
ENV
HOME /app
ENV
PORT 3000
RUN
mkdir
-p
/app
COPY
. /app/
RUN
/app/buildpack/bin/compile /app
EXPOSE
3000
CMD
/app/bin/boot
FROM
hone/static:14
spec/simple_spec.rb
View file @
cf80709c
require_relative
"spec_helper"
require_relative
"support/buildpack_runner"
require_relative
"support/app_runner"
require_relative
"support/buildpack_builder"
describe
"Simple"
do
let
(
:bp
)
{
BuildpackRunner
.
new
(
"hello_world"
)
}
let
(
:debug
)
{
false
}
let
(
:app
)
{
AppRunner
.
new
(
"hello_world"
,
debug
)
}
before
{
BuildpackBuilder
.
new
(
debug
)
}
after
do
b
p
.
destroy
ap
p
.
destroy
end
it
"should serve out of public_html by default"
do
response
=
b
p
.
get
(
"/"
)
response
=
ap
p
.
get
(
"/"
)
expect
(
response
.
code
).
to
eq
(
"200"
)
expect
(
response
.
body
.
chomp
).
to
eq
(
"Hello World"
)
end
...
...
spec/support/
buildpack
_runner.rb
→
spec/support/
app
_runner.rb
View file @
cf80709c
...
...
@@ -5,7 +5,7 @@ require "json"
require
"docker"
require_relative
"path_helper"
class
Buildpack
Runner
class
App
Runner
include
PathHelper
HOST_PORT
=
"3000"
...
...
@@ -15,14 +15,13 @@ class BuildpackRunner
def
initialize
(
fixture
,
debug
=
false
)
@debug
=
debug
@image
=
build_image
(
fixture
)
puts
@image
.
id
if
@debug
@container
=
Docker
::
Container
.
create
(
'Image'
=>
@image
.
id
,
'HostConfig'
=>
{
'PortBindings'
=>
{
"
#{
CONTAINER_PORT
}
/tcp"
=>
[{
"HostIp"
=>
HOST_IP
,
"HostPort"
:
HOST_PORT
,
"HostPort"
:
HOST_PORT
,
}]
}
}
...
...
@@ -59,8 +58,6 @@ class BuildpackRunner
image
=
nil
Dir
.
mktmpdir
do
|
tmpdir
|
fixture_path
=
fixtures_path
(
fixture
)
dest_bp_dir
=
Pathname
.
new
(
File
.
join
(
tmpdir
,
"buildpack"
))
print_output
=
if
@debug
->
(
chunk
)
{
...
...
@@ -71,11 +68,8 @@ class BuildpackRunner
->
(
chunk
)
{
nil
}
end
FileUtils
.
mkdir_p
(
dest_bp_dir
)
FileUtils
.
cp_r
(
buildpack_path
(
"bin"
),
dest_bp_dir
)
FileUtils
.
cp_r
(
buildpack_path
(
"scripts"
),
dest_bp_dir
)
FileUtils
.
cp_r
(
Dir
.
glob
(
fixture_path
+
"*"
),
tmpdir
)
image
=
Docker
::
Image
.
build_from_dir
(
tmpdir
,
&
print_output
)
FileUtils
.
cp_r
(
Dir
.
glob
(
fixtures_path
(
fixture
)
+
"*"
),
tmpdir
)
image
=
Docker
::
Image
.
build_from_dir
(
tmpdir
,
'rm'
=>
true
,
&
print_output
)
end
image
...
...
spec/support/buildpack_builder.rb
0 → 100644
View file @
cf80709c
require
"tmpdir"
require
"fileutils"
require
"docker"
require_relative
"path_helper"
class
BuildpackBuilder
include
PathHelper
TAG
=
"hone/static:14"
def
initialize
(
debug
=
false
)
@debug
=
debug
@image
=
build_image
end
def
build_image
print_output
=
if
@debug
->
(
chunk
)
{
json
=
JSON
.
parse
(
chunk
)
puts
json
[
"stream"
]
}
else
->
(
chunk
)
{
nil
}
end
Docker
::
Image
.
build_from_dir
(
buildpack_path
.
to_s
,
't'
=>
TAG
,
'rm'
=>
true
,
&
print_output
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment