@@ -26,7 +26,6 @@ import (
26
26
"github.com/docker/docker/api/types/strslice"
27
27
28
28
"github.com/nitrictech/boxygen/pkg/backend/dockerfile"
29
- "github.com/nitrictech/cli/pkg/utils"
30
29
)
31
30
32
31
type javascript struct {
@@ -45,7 +44,22 @@ func (t *javascript) ContainerName() string {
45
44
}
46
45
47
46
func (t * javascript ) FunctionDockerfileForCodeAsConfig (w io.Writer ) error {
48
- return utils .NewNotSupportedErr ("code-as-config not supported on " + string (t .rte ))
47
+ con , err := dockerfile .NewContainer (dockerfile.NewContainerOpts {
48
+ From : "node:alpine" ,
49
+ Ignore : []string {"node_modules/" , ".nitric/" , ".git/" , ".idea/" },
50
+ })
51
+ if err != nil {
52
+ return err
53
+ }
54
+
55
+ con .Run (dockerfile.RunOptions {Command : []string {"yarn" , "global" , "add" , "nodemon" }})
56
+ con .Config (dockerfile.ConfigOptions {
57
+ Entrypoint : []string {"node" },
58
+ WorkingDir : "/app/" ,
59
+ })
60
+
61
+ _ , err = w .Write ([]byte (strings .Join (con .Lines (), "\n " )))
62
+ return err
49
63
}
50
64
51
65
func (t * javascript ) FunctionDockerfile (funcCtxDir , version , provider string , w io.Writer ) error {
@@ -82,8 +96,8 @@ func (t *javascript) FunctionDockerfile(funcCtxDir, version, provider string, w
82
96
func (t * javascript ) LaunchOptsForFunctionCollect (runCtx string ) (LaunchOpts , error ) {
83
97
return LaunchOpts {
84
98
Image : t .DevImageName (),
85
- Entrypoint : strslice.StrSlice {"ts- node" },
86
- Cmd : strslice.StrSlice {"-T " + " /app/" + filepath .ToSlash (t .handler )},
99
+ Entrypoint : strslice.StrSlice {"node" },
100
+ Cmd : strslice.StrSlice {"/app/" + filepath .ToSlash (t .handler )},
87
101
TargetWD : "/app" ,
88
102
Mounts : []mount.Mount {
89
103
{
@@ -106,6 +120,6 @@ func (t *javascript) LaunchOptsForFunction(runCtx string) (LaunchOpts, error) {
106
120
},
107
121
TargetWD : "/app" ,
108
122
Entrypoint : strslice.StrSlice {"nodemon" },
109
- Cmd : strslice.StrSlice {"--watch" , "/app/**" , "--ext" , "ts,js,json" , "--exec" , "ts- node -T " + "/app/" + filepath .ToSlash (t .handler )},
123
+ Cmd : strslice.StrSlice {"--watch" , "/app/**" , "--ext" , "ts,js,json" , "--exec" , "node " + "/app/" + filepath .ToSlash (t .handler )},
110
124
}, nil
111
125
}
0 commit comments