Skip to content

Commit fab03c7

Browse files
committed
Set shell options during docker builds
Set stricter options for shell commands, particulary `pipefail` so that commands like `curl … | bash` fail the build when the curl download fails. Without this option, the shell will only consider the exit code of the last command in the pipeline, which might erroneously succeed.
1 parent a9584c0 commit fab03c7

13 files changed

+27
-0
lines changed

docker/base/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# syntax = docker/dockerfile:experimental
22
FROM debian:bookworm-slim AS builder
3+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
34
ARG PULUMI_VERSION
45
RUN apt-get update -y && \
56
apt-get upgrade -y && \
@@ -14,6 +15,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1415
# The runtime container
1516
# This is our base container, so let's copy all the runtimes to .pulumi/bin
1617
FROM debian:bookworm-slim
18+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1719
LABEL org.opencontainers.image.description="Pulumi CLI container, bring your own SDK"
1820
WORKDIR /pulumi
1921
COPY --from=builder /root/.pulumi/bin bin

docker/base/Dockerfile.ubi

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# syntax = docker/dockerfile:experimental
22
FROM redhat/ubi8-minimal:latest as builder
3+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
34
ARG PULUMI_VERSION
45
RUN microdnf install -y \
56
curl \
@@ -14,6 +15,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1415
# The runtime container
1516
# This is our base container, so let's copy all the runtimes to .pulumi/bin
1617
FROM redhat/ubi8-minimal:latest
18+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1719
LABEL org.opencontainers.image.description="Pulumi CLI container, bring your own SDK"
1820
WORKDIR /pulumi
1921
COPY --from=builder /root/.pulumi/bin bin

docker/dotnet/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# syntax = docker/dockerfile:experimental
22

33
FROM debian:bookworm-slim AS builder
4+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
45
ARG PULUMI_VERSION
56
RUN apt-get update -y && \
67
apt-get upgrade -y && \
@@ -15,6 +16,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1516

1617
# The runtime container
1718
FROM debian:bookworm-slim
19+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1820
LABEL org.opencontainers.image.description="Pulumi CLI container for dotnet"
1921
WORKDIR /pulumi/projects
2022

docker/dotnet/Dockerfile.ubi

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# syntax = docker/dockerfile:experimental
22
# Interim container so we can copy pulumi binaries
33
FROM redhat/ubi8-minimal:latest as builder
4+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
45
ARG PULUMI_VERSION
56
RUN microdnf install -y \
67
curl \
@@ -11,6 +12,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1112

1213
# The runtime container
1314
FROM redhat/ubi8-minimal:latest
15+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1416
ARG LANGUAGE_VERSION
1517
LABEL org.opencontainers.image.description="Pulumi CLI container for dotnet"
1618
WORKDIR /pulumi/projects

docker/go/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Build container
66
FROM ubuntu:bionic AS builder
7+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
78

89
ARG PULUMI_VERSION
910
ARG GO_RUNTIME_VERSION=1.21.1
@@ -52,6 +53,7 @@ RUN case $(uname -m) in \
5253

5354
# The runtime container
5455
FROM debian:11-slim
56+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
5557
LABEL org.opencontainers.image.description="Pulumi CLI container for go"
5658
WORKDIR /pulumi/projects
5759

docker/go/Dockerfile.ubi

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# syntax = docker/dockerfile:experimental
22
# Interim container so we can copy pulumi binaries
33
FROM redhat/ubi8-minimal:latest as builder
4+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
45
ARG PULUMI_VERSION
56
RUN microdnf install -y \
67
curl \
@@ -24,6 +25,7 @@ RUN curl -fsSLo /tmp/go.tgz https://golang.org/dl/go${RUNTIME_VERSION}.linux-amd
2425

2526
# The runtime container
2627
FROM redhat/ubi8-minimal:latest
28+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
2729
LABEL org.opencontainers.image.description="Pulumi CLI container for go"
2830
WORKDIR /pulumi/projects
2931

docker/java/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Interim container so we can copy pulumi binaries
33
# Must be defined first
44
FROM debian:bookworm-slim AS builder
5+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
56
ARG PULUMI_VERSION
67
RUN apt-get update -y && \
78
apt-get upgrade -y && \
@@ -16,6 +17,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1617

1718
# The runtime container
1819
FROM debian:bookworm-slim
20+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1921
LABEL org.opencontainers.image.description="Pulumi CLI container for java"
2022
WORKDIR /pulumi/projects
2123

docker/java/Dockerfile.ubi

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Interim container so we can copy pulumi binaries
33
# Must be defined first
44
FROM redhat/ubi8-minimal:latest as builder
5+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
56
ARG PULUMI_VERSION
67
RUN microdnf install -y \
78
curl \
@@ -14,6 +15,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1415

1516
# The runtime container
1617
FROM redhat/ubi8-minimal:latest
18+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1719
LABEL org.opencontainers.image.description="Pulumi CLI container for Java"
1820
WORKDIR /pulumi/projects
1921

docker/nodejs/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ARG LANGUAGE_VERSION
55

66
FROM debian:bookworm-slim AS builder
7+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
78
ARG PULUMI_VERSION
89
RUN apt-get update -y && \
910
apt-get upgrade -y && \
@@ -18,6 +19,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1819

1920
# The runtime container
2021
FROM node:${LANGUAGE_VERSION}-bookworm-slim
22+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
2123
LABEL org.opencontainers.image.description="Pulumi CLI container for nodejs"
2224
WORKDIR /pulumi/projects
2325

docker/nodejs/Dockerfile.ubi

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# syntax = docker/dockerfile:experimental
22
# Interim container so we can copy pulumi binaries
33
FROM redhat/ubi8-minimal:latest as builder
4+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
45
ARG PULUMI_VERSION
56
RUN microdnf install -y \
67
curl \
@@ -11,6 +12,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1112

1213
# The runtime container
1314
FROM redhat/ubi8-minimal:latest
15+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1416
ARG LANGUAGE_VERSION
1517
LABEL org.opencontainers.image.description="Pulumi CLI container for nodejs"
1618
WORKDIR /pulumi/projects

docker/pulumi/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM debian:12 AS base
2+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
23

34
# These values are passed in by the build system automatically. The options are: arm64, amd64
45
# See: https://docs.docker.com/build/building/variables/#pre-defined-build-arguments
@@ -170,6 +171,7 @@ ENTRYPOINT ["pulumi"]
170171
########################################################################
171172

172173
FROM base AS nonroot
174+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
173175

174176
LABEL "repository"="https://github.com/pulumi/pulumi"
175177
LABEL "homepage"="https://pulumi.com"
@@ -199,6 +201,7 @@ RUN helm repo add stable https://charts.helm.sh/stable && \
199201
########################################################################
200202

201203
FROM base AS build-environment
204+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
202205

203206
ARG TARGETARCH
204207

docker/python/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ARG LANGUAGE_VERSION
55

66
FROM debian:bookworm-slim AS builder
7+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
78
ARG PULUMI_VERSION
89
RUN apt-get update -y && \
910
apt-get upgrade -y && \
@@ -17,6 +18,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1718

1819
# The runtime container
1920
FROM python:${LANGUAGE_VERSION}-slim-bookworm
21+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
2022
LABEL org.opencontainers.image.description="Pulumi CLI container for python"
2123
WORKDIR /pulumi/projects
2224

docker/python/Dockerfile.ubi

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# syntax = docker/dockerfile:experimental
22
# Interim container so we can copy pulumi binaries
33
FROM redhat/ubi8-minimal:latest as builder
4+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
45
ARG PULUMI_VERSION
56
RUN microdnf install -y \
67
gzip \
@@ -10,6 +11,7 @@ RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION
1011

1112
# The runtime container
1213
FROM redhat/ubi8-minimal:latest
14+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
1315
ARG LANGUAGE_VERSION
1416
LABEL org.opencontainers.image.description="Pulumi CLI container for python"
1517
WORKDIR /pulumi/projects

0 commit comments

Comments
 (0)