New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker image generation #1484
Merged
Merged
Docker image generation #1484
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8250f03
first attempt
Finomnis 40c115c
attempt to fix circle.yml
Finomnis a1e3bed
fixed hpxcxx command
Finomnis 83a25c6
added --hpx:bind=none
Finomnis cd7cbd6
added docker-compile.pl
Finomnis f77a2c6
added license header
Finomnis d33c492
adding explanation for docker-compile.pl
Finomnis 36834e2
switched deployment to branch master
Finomnis f4c00ca
added Docker to README
Finomnis bb5efbd
README finetuning
Finomnis 4f43eff
moved Dockerfile and .dockerignore to tools/docker/
Finomnis c8d7eb4
more finetuning of README
Finomnis c56ec46
fix in README
Finomnis 8cdeae0
final touches
Finomnis 681eb46
bug fix
Finomnis File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,6 @@ | ||
# Copyright (c) 2015 Martin Stumpf | ||
# | ||
# Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
/.git |
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,16 @@ | ||
# Copyright (c) 2015 Martin Stumpf | ||
# | ||
# Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
FROM stellargroup/build_env:debian_clang | ||
|
||
ADD . /hpx | ||
|
||
RUN cd /hpx/build && make install && cd / | ||
RUN rm -rf /hpx | ||
|
||
RUN ldconfig | ||
|
||
CMD bash | ||
WORKDIR / |
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
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,142 @@ | ||
#!/usr/bin/env perl | ||
|
||
# copyright: Maciej Pasternacki | ||
# http://3ofcoins.net/2013/09/22/flat-docker-images/ | ||
# | ||
# TODO: replace with something homemade | ||
|
||
|
||
use feature 'switch'; | ||
use strict; | ||
use warnings; | ||
|
||
no if $] >= 5.018, warnings => "experimental::smartmatch"; | ||
|
||
use Data::Dumper; | ||
use File::Basename; | ||
use File::Copy; | ||
use File::Path qw/make_path/; | ||
use File::Temp qw/tempdir/; | ||
|
||
use JSON; | ||
|
||
if ($#ARGV != 0) { | ||
print "\nUsage: docker-compile.pl commit-tag\n"; | ||
exit; | ||
} | ||
|
||
our ( $from, $author, %metadata, @commands, $tmpdir, $tmpcount, $prefix ); | ||
|
||
|
||
$tmpdir = tempdir(CLEANUP => !$ENV{LEAVE_TMPDIR}); | ||
$tmpcount = 0; | ||
$prefix = ''; | ||
|
||
print "*** Working directory: $tmpdir\n" if $ENV{LEAVE_TMPDIR}; | ||
|
||
open DOCKERFILE, '<Dockerfile' or die; | ||
while ( <DOCKERFILE> ) { | ||
chomp; | ||
|
||
# handle long lines | ||
$_ = "$prefix$_"; | ||
$prefix = ''; | ||
if ( /\\$/ ) { | ||
s/\\$//; | ||
$prefix="$_\n"; | ||
next; | ||
} | ||
|
||
s/^\s*//; | ||
/^#/ and next; | ||
/^$/ and next; | ||
|
||
my ($cmd, $args) = split(/\s+/, $_, 2); | ||
given ( uc $cmd ) { | ||
# building the image | ||
when ('FROM') { $from = $args } | ||
when ('RUN') { push @commands, $args } | ||
when ('ADD') { | ||
$tmpcount++; | ||
my ( $src, $dest ) = split ' ', $args, 2; | ||
|
||
if ( $src =~ /^https?:/ ) { | ||
my $basename = basename($src); | ||
my $target = "$tmpdir/dl/$tmpcount/$basename"; | ||
make_path "$tmpdir/dl/$tmpcount"; | ||
system('wget', '-O', $target, $src) == 0 or die; | ||
$src = $target; | ||
} | ||
|
||
my $local = "$tmpdir/$tmpcount"; | ||
|
||
given ( $src ) { | ||
when ( /\.(tar(\.(gz|bz2|xz))?|tgz)$/ ) { | ||
mkdir $local; | ||
system('tar', '-C', $local, '-xf', $_) == 0 or die; | ||
push @commands, "mkdir -p '$dest'", "( cd /.data/$tmpcount ; cp -a . '$dest' )"; | ||
} | ||
when ( -f $_ ) { | ||
$dest .= basename($_) if ( $dest =~ /\/$/ ); | ||
system('cp', '-a', $_, $local) == 0 or die; | ||
push @commands, "mkdir -p '".dirname($dest)."'", "cp -a /.data/$tmpcount '$dest'"; | ||
} | ||
when ( -d $_ ) { | ||
# Handle trailing slash combinations properly: | ||
# - `$src=/dir, $dest=/foo -> /foo` | ||
# - `$src=/dir, $dest=/foo/ -> /foo/dir` | ||
# - `$src=/dir/, $dest=/foo -> /foo` | ||
# - `$src=/dir/, $dest=/foo/ -> /foo` | ||
$dest .= basename($_) if ( $_ !~ /\/$/ && $dest =~ /\/$/ ); | ||
|
||
system('cp', '-a', $_, $local) == 0 or die; | ||
push @commands, "mkdir -p '$dest'", "( cd /.data/$tmpcount ; cp -a . '$dest' )"; | ||
} | ||
default { die } | ||
} | ||
} | ||
|
||
# image metadata | ||
when ('MAINTAINER') { $author = $args } | ||
when ('CMD') { $metadata{Cmd} = eval { decode_json($args) } || ['sh', '-c', $args] } | ||
when ('ENTRYPOINT') { $metadata{Entrypoint} = eval { decode_json($args) } || ['sh', '-c', $args] } | ||
when ('WORKDIR') { $metadata{WorkingDir} = $args } | ||
when ('USER') { $metadata{User} = $args } | ||
when ('EXPOSE') { push @{ $metadata{PortSpecs} ||= [] }, split(' ',$args); } | ||
when ('ENV') { | ||
my ( $k, $v ) = split(/s+/, $args, 2); | ||
push @commands, "export $k='$v'"; | ||
push @{ $metadata{Env} ||= [] }, "$k=$v"; | ||
} | ||
when ('VOLUME') { | ||
# This seems to be a NOP in `docker build`. | ||
# push @{ $metadata{VolumesFrom} ||= [] }, $args | ||
} | ||
} | ||
} | ||
close DOCKERFILE; | ||
|
||
open SETUP, ">$tmpdir/setup.sh" or die; | ||
print SETUP join("\n", "#!/bin/sh", "set -e -x", @commands), "\ntouch /.data/FINI\n"; | ||
close SETUP; | ||
chmod 0755, "$tmpdir/setup.sh"; | ||
|
||
our @run = ('docker', 'run', "-cidfile=$tmpdir/CID", '-v', "$tmpdir:/.data", $from, "/.data/setup.sh"); | ||
print "*** ", join(' ', @run), "\n"; | ||
system(@run) == 0 or die; | ||
|
||
die "unfinished, not committing\n" unless -f "$tmpdir/FINI"; | ||
|
||
sleep 15; # docker container is not always immediately up to a commit, let's give it time to cool off. | ||
|
||
open CID, "<$tmpdir/CID" or die; | ||
our $cid = <CID>; | ||
close CID; | ||
|
||
our @commit = ( 'docker', 'commit' ); | ||
push @commit, "-author=$author" if defined $author; | ||
push @commit, "-run=" . encode_json(\%metadata) if %metadata; | ||
push @commit, $cid; | ||
push @commit, $ARGV[0]; | ||
print "*** ", join(' ', @commit), "\n"; | ||
exec(@commit); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the Boost License header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
U sure? We don't even have the copyright for this file, I pulled it in from that dude. He published it via gist without copyright note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He added his copyright but published it without a license (which means it's in the public domain). That entitles us to relicense it under the Boost license, I don't see a problem with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, technically he didn't even add his name in, I did that ;)
Should I strip his name out? Or is it polite to leave that in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave his copyright in place, credit where credit is due...