Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* None

[ BUG FIXES ]
* GH #1851: Generate Dockerfile inside the resolved application directory.
* GH #1794: Add support for HTTP QUERY method. Old style plugins that
register query will die at load, and apps with their own sub query
will get a redefine warning. (Mohammad S Anwar)
Expand Down
2 changes: 1 addition & 1 deletion lib/Dancer2/CLI/Gen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ sub run {
}

if( $self->docker ) {
push @$files_to_copy, [ path( $self->parent_command->_dist_dir, 'docker/Dockerfile' ), "$app_name/Dockerfile" ];
push @$files_to_copy, [ path( $self->parent_command->_dist_dir, 'docker/Dockerfile' ), path( $app_path, 'Dockerfile' ) ];
}

my $vars = {
Expand Down
29 changes: 29 additions & 0 deletions t/e2e/cli/gen.t
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,35 @@ subtest 'the application directory is named after the dashed app name (fixed)' =
}
};

subtest '-c puts Dockerfile inside the application directory' => sub {
# File::Share needs the source module loaded to find this checkout's
# Dockerfile template when the command runs outside the repository.
local $ENV{'PERL5OPT'} = join ' ', ( $ENV{'PERL5OPT'} || () ), '-MDancer2';

for my $directory ( undef, 'custom-app' ) {
my $cwd = path('.')->absolute;
my $work = path( tempdir( CLEANUP => 1 ) );
$work->child('out')->mkpath;
my @directory = defined $directory ? ( '-d', $directory ) : ();

chdir $work->stringify or die "cannot chdir to $work: $!";
my $res = gen( '-a', 'Docker::App', '-c', '--path', 'out', @directory );
chdir $cwd->stringify or die "cannot chdir back to $cwd: $!";

my $generated = $work->child( 'out', $directory // 'Docker-App' );
is( $res->{'status'}, 0, 'generating a Docker application succeeds' )
or diag "STDERR:\n$res->{stderr}\nSTDOUT:\n$res->{stdout}";
ok( $generated->child('Dockerfile')->is_file,
"Dockerfile is inside $generated" );
like( slurp( $generated->child('Dockerfile') ), qr{^WORKDIR /srv/Docker::App\r?$}m,
'the Dockerfile template is rendered for the application' );
ok( !$work->child('Docker::App')->exists,
'no directory named after the raw application name is created' );
like( slurp( $generated->child('MANIFEST') ), qr/^Dockerfile\r?$/m,
'MANIFEST lists Dockerfile relative to the application directory' );
}
};

subtest 'MANIFEST.SKIP gets the relative dashed name (fixed)' => sub {
# This used to build the appended line from the full filesystem path the
# app was generated into, so it could never match anything -- MANIFEST.SKIP
Expand Down