Skip to content

Commit d8b04e8

Browse files
authored
fix: fix conditional execution of chained build/install commands (#11)
1 parent cb97976 commit d8b04e8

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

runtime/bun.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,15 @@ FROM base AS deps
144144
WORKDIR /app
145145
COPY package.json bun.lockb ./
146146
ARG INSTALL_CMD="bun install"
147-
ENV INSTALL_CMD=${INSTALL_CMD}
148-
RUN if [ ! -z "${INSTALL_CMD}" ]; then $INSTALL_CMD; fi
147+
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
149148
150149
FROM base AS builder
151150
WORKDIR /app
152151
COPY --from=deps /app/node_modules* ./node_modules
153152
COPY . .
154153
ENV NODE_ENV=production
155154
ARG BUILD_CMD={{.BuildCMD}}
156-
ENV BUILD_CMD=${BUILD_CMD}
157-
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
155+
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
158156
159157
FROM oven/bun:${VERSION}-slim AS runtime
160158
WORKDIR /app

runtime/deno.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ USER nonroot:nonroot
192192
193193
ENV PORT=8080
194194
ARG INSTALL_CMD={{.InstallCMD}}
195-
ENV INSTALL_CMD=${INSTALL_CMD}
196-
RUN if [ ! -z "${INSTALL_CMD}" ]; then $INSTALL_CMD; fi
195+
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
197196
198197
ARG START_CMD={{.StartCMD}}
199198
ENV START_CMD=${START_CMD}

runtime/java.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ COPY src src
151151
RUN mvn install
152152
153153
ARG BUILD_CMD={{.BuildCMD}}
154-
RUN if [ ! -z "${BUILD_CMD}" ]; then ${BUILD_CMD}; fi
154+
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
155155
156156
FROM eclipse-temurin:${VERSION}-jdk AS runtime
157157
WORKDIR /app
@@ -185,7 +185,7 @@ COPY gradle/ ./gradle/
185185
COPY src src
186186
187187
ARG BUILD_CMD={{.BuildCMD}}
188-
RUN if [ ! -z "${BUILD_CMD}" ]; then ${BUILD_CMD}; fi
188+
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
189189
190190
FROM eclipse-temurin:${VERSION}-jdk AS runtime
191191
WORKDIR /app

runtime/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ COPY --from=deps /app/node_modules* ./node_modules
180180
COPY . .
181181
ENV NODE_ENV=production
182182
ARG BUILD_CMD={{.BuildCMD}}
183-
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
183+
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
184184
185185
FROM base AS runtime
186186
WORKDIR /app

runtime/php.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ COPY . .
145145
146146
ARG INSTALL_CMD={{.InstallCMD}}
147147
ARG BUILD_CMD={{.BuildCMD}}
148-
RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${INSTALL_CMD}" > dep.sh; sh dep.sh; fi
149-
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
148+
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
149+
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
150150
151151
FROM php:${VERSION}-apache AS runtime
152152

runtime/python.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ RUN chown -R nonroot:nonroot /app
167167
168168
COPY --chown=nonroot:nonroot . .
169169
ARG INSTALL_CMD={{.InstallCMD}}
170-
RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${INSTALL_CMD}" > dep.sh; sh dep.sh; fi
170+
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
171171
172172
ENV PORT=8080
173173
ENV PYTHONDONTWRITEBYTECODE=1

runtime/ruby.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ ENV NODE_ENV=production
143143
RUN chown -R nonroot:nonroot /app
144144
COPY --chown=nonroot:nonroot . .
145145
146-
RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${INSTALL_CMD}" > dep.sh; sh dep.sh; fi
147-
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
146+
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
147+
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
148148
149149
ENV PORT=8080
150150
USER nonroot:nonroot

runtime/rust.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (d *Rust) GenerateDockerfile(path string) ([]byte, error) {
9797
}
9898

9999
var rustlangTemplate = strings.TrimSpace(`
100+
ARG BUILDPLATFORM=linux
100101
FROM --platform=${BUILDPLATFORM} messense/cargo-zigbuild:latest AS build
101102
WORKDIR /app
102103
COPY . .

0 commit comments

Comments
 (0)