Skip to content

Commit

Permalink
fix: fix conditional execution of chained build/install commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredLunde committed May 17, 2024
1 parent cb97976 commit 92054dc
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions runtime/bun.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,15 @@ FROM base AS deps
WORKDIR /app
COPY package.json bun.lockb ./
ARG INSTALL_CMD="bun install"
ENV INSTALL_CMD=${INSTALL_CMD}
RUN if [ ! -z "${INSTALL_CMD}" ]; then $INSTALL_CMD; fi
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules* ./node_modules
COPY . .
ENV NODE_ENV=production
ARG BUILD_CMD={{.BuildCMD}}
ENV BUILD_CMD=${BUILD_CMD}
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
FROM oven/bun:${VERSION}-slim AS runtime
WORKDIR /app
Expand Down
3 changes: 1 addition & 2 deletions runtime/deno.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ USER nonroot:nonroot
ENV PORT=8080
ARG INSTALL_CMD={{.InstallCMD}}
ENV INSTALL_CMD=${INSTALL_CMD}
RUN if [ ! -z "${INSTALL_CMD}" ]; then $INSTALL_CMD; fi
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
ARG START_CMD={{.StartCMD}}
ENV START_CMD=${START_CMD}
Expand Down
4 changes: 2 additions & 2 deletions runtime/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ COPY src src
RUN mvn install
ARG BUILD_CMD={{.BuildCMD}}
RUN if [ ! -z "${BUILD_CMD}" ]; then ${BUILD_CMD}; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
FROM eclipse-temurin:${VERSION}-jdk AS runtime
WORKDIR /app
Expand Down Expand Up @@ -185,7 +185,7 @@ COPY gradle/ ./gradle/
COPY src src
ARG BUILD_CMD={{.BuildCMD}}
RUN if [ ! -z "${BUILD_CMD}" ]; then ${BUILD_CMD}; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
FROM eclipse-temurin:${VERSION}-jdk AS runtime
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion runtime/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ COPY --from=deps /app/node_modules* ./node_modules
COPY . .
ENV NODE_ENV=production
ARG BUILD_CMD={{.BuildCMD}}
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
FROM base AS runtime
WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions runtime/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ COPY . .
ARG INSTALL_CMD={{.InstallCMD}}
ARG BUILD_CMD={{.BuildCMD}}
RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${INSTALL_CMD}" > dep.sh; sh dep.sh; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
FROM php:${VERSION}-apache AS runtime
Expand Down
2 changes: 1 addition & 1 deletion runtime/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ RUN chown -R nonroot:nonroot /app
COPY --chown=nonroot:nonroot . .
ARG INSTALL_CMD={{.InstallCMD}}
RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${INSTALL_CMD}" > dep.sh; sh dep.sh; fi
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
ENV PORT=8080
ENV PYTHONDONTWRITEBYTECODE=1
Expand Down
4 changes: 2 additions & 2 deletions runtime/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ ENV NODE_ENV=production
RUN chown -R nonroot:nonroot /app
COPY --chown=nonroot:nonroot . .
RUN if [ ! -z "${INSTALL_CMD}" ]; then echo "${INSTALL_CMD}" > dep.sh; sh dep.sh; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then $BUILD_CMD; fi
RUN if [ ! -z "${INSTALL_CMD}" ]; then sh -c "$INSTALL_CMD"; fi
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi
ENV PORT=8080
USER nonroot:nonroot
Expand Down
1 change: 1 addition & 0 deletions runtime/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (d *Rust) GenerateDockerfile(path string) ([]byte, error) {
}

var rustlangTemplate = strings.TrimSpace(`
ARG BUILDPLATFORM=linux
FROM --platform=${BUILDPLATFORM} messense/cargo-zigbuild:latest AS build
WORKDIR /app
COPY . .
Expand Down

0 comments on commit 92054dc

Please sign in to comment.