File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ export default function dockerize(
1010 if ( ! last_cmd ) {
1111 throw new Error ( "build_cmds must contain at least one valid execution command" ) ;
1212 }
13- const execute_cmd = "CMD " + JSON . stringify ( last_cmd . split ( " " ) ) ;
14- const build_steps = run_cmd . filter ( Boolean ) . map ( ( cmd ) => `RUN ${ cmd } ` ) ;
13+ let execute_cmd = "CMD " + JSON . stringify ( last_cmd . split ( " " ) ) ;
14+ let build_steps = run_cmd . filter ( Boolean ) . map ( ( cmd ) => `RUN ${ cmd } ` ) ;
1515 if ( stack == "Python" ) {
1616 dockerfile = [
1717 "FROM python:3.12-slim AS builder" ,
@@ -56,7 +56,7 @@ export default function dockerize(
5656 "WORKDIR /app" ,
5757 "COPY . ." ,
5858 "RUN if [ -f go.mod ]; then go mod download; fi" ,
59- ...build_steps ,
59+ ...build_steps . map ( step => step . replace ( / R U N g o r u n ( . + ) / , "RUN go build -o app_binary $1" ) ) ,
6060 "RUN find . -type f ! -executable -delete && rm -rf vendor/ .git/ *.go go.*" ,
6161 "" ,
6262 "FROM alpine:3.19" ,
@@ -66,7 +66,7 @@ export default function dockerize(
6666 "COPY --from=builder /app /app" ,
6767 "USER appuser" ,
6868 `EXPOSE ${ port } ` ,
69- execute_cmd ,
69+ last_cmd . startsWith ( "go run" ) ? 'CMD ["./app_binary"]' : execute_cmd ,
7070 ] . join ( "\n" ) ;
7171 }
7272 return dockerfile . toString ( ) ;
You can’t perform that action at this time.
0 commit comments