@@ -3,7 +3,6 @@ package runtime
33import (
44 "bufio"
55 "bytes"
6- "encoding/json"
76 "fmt"
87 "log/slog"
98 "os"
@@ -117,27 +116,12 @@ func (d *Ruby) GenerateDockerfile(path string) ([]byte, error) {
117116 See https://flexstack.com/docs/languages-and-frameworks/autogenerate-dockerfile` , * version , packageManager , installCMD , buildCMD , startCMD ),
118117 )
119118
120- if installCMD != "" {
121- installCMDJSON , _ := json .Marshal (installCMD )
122- installCMD = string (installCMDJSON )
123- }
124-
125- if buildCMD != "" {
126- buildCMDJSON , _ := json .Marshal (buildCMD )
127- buildCMD = string (buildCMDJSON )
128- }
129-
130- if startCMD != "" {
131- startCMDJSON , _ := json .Marshal (startCMD )
132- startCMD = string (startCMDJSON )
133- }
134-
135119 var buf bytes.Buffer
136120 if err := tmpl .Option ("missingkey=zero" ).Execute (& buf , map [string ]string {
137121 "Version" : * version ,
138- "InstallCMD" : installCMD ,
139- "BuildCMD" : buildCMD ,
140- "StartCMD" : startCMD ,
122+ "InstallCMD" : safeCommand ( installCMD ) ,
123+ "BuildCMD" : safeCommand ( buildCMD ) ,
124+ "StartCMD" : safeCommand ( startCMD ) ,
141125 }); err != nil {
142126 return nil , fmt .Errorf ("Failed to execute template" )
143127 }
@@ -159,7 +143,7 @@ ENV NODE_ENV=production
159143RUN chown -R nonroot:nonroot /app
160144COPY --chown=nonroot:nonroot . .
161145
162- RUN if [ ! -z "${INSTALL_CMD}" ]; then $ INSTALL_CMD; fi
146+ RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${ INSTALL_CMD}" > dep.sh; sh dep.sh; fi
163147RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
164148
165149ENV PORT=8080
0 commit comments