@@ -4,6 +4,7 @@ import fs from "fs-extra";
44import Handlebars from "handlebars" ;
55import * as path from "path" ;
66import { fileURLToPath } from "url" ;
7+ import { FaableApp } from "../../api/FaableApi" ;
78
89const __filename = fileURLToPath ( import . meta. url ) ;
910const __dirname = path . dirname ( __filename ) ;
@@ -27,28 +28,37 @@ const docker_template = Handlebars.compile(dockerfile);
2728const entrypoint_template = Handlebars . compile ( entrypoint ) ;
2829
2930interface BuildConfig {
30- app_name : string ;
31+ app : FaableApp ;
3132 workdir : string ;
3233 template_context : {
3334 from : string ;
34- build_script : string ;
3535 start_script : string ;
3636 } ;
3737}
3838
39- export const build_docker = async ( props : BuildConfig ) => {
40- const { app_name , workdir, template_context } = props ;
39+ export const bundle_docker = async ( props : BuildConfig ) => {
40+ const { app , workdir, template_context } = props ;
4141
4242 const entrypoint_custom = entrypoint_template ( template_context ) ;
4343 const dockerfile = docker_template ( {
4444 ...template_context ,
4545 entry_script : entrypoint_custom ,
4646 } ) ;
47- // console.log(dockerfile);
4847
49- await cmd (
50- "/bin/bash" ,
51- [ "-c" , `docker build -t app ${ workdir } -f-<<EOF\n${ dockerfile } \nEOF` ] ,
52- { enableOutput : true }
53- ) ;
48+ log . info ( `📦 Packaging inside a docker image` ) ;
49+ const tagname = app . id ;
50+
51+ const timeout = 10 * 60 * 1000 ; // 10 minute timeout
52+ const command = [
53+ "-c" ,
54+ `docker build -t ${ tagname } ${ workdir } -f -<<EOF\n${ dockerfile } \nEOF` ,
55+ ] ;
56+ console . log ( command . join ( " " ) ) ;
57+ await cmd ( "/bin/bash" , command , { timeout, enableOutput : true } ) ;
58+
59+ log . info ( `⚙️ Image ready [tag:${ tagname } ]` ) ;
60+
61+ return {
62+ tagname,
63+ } ;
5464} ;
0 commit comments