Skip to content

Commit

Permalink
Bug fixes and improvements to prctl (kubeflow#718)
Browse files Browse the repository at this point in the history
* Fix the docker image; I switched the base image to alpine but
didn't update the pkg commands from apt to apk.

* Refactor the code to make it easier to write a unittest for the error
  regexes.

  * Use a global map for the regexes
  * Use named constants for the particular error types

* We should be using CombinedOutput in order to get stdout and stderr
  when shelling out.

* Mark required flags
* Use working directory as default directory
* Change flag name for push to refspec

* Add an option to format logs as json
  * This is needed when running in cluster and using stackdriver so
    that multi line entries and metadata fields like level and filename
    are recorded as structured entries.

* Add kustomize to the prctl image

  * This is a quick fix so we can use the prctl image to run hydration
    of manifests
  • Loading branch information
jlewi authored Jul 5, 2020
1 parent 11317c5 commit 0e522ee
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 91 deletions.
33 changes: 19 additions & 14 deletions go/Dockerfile.prctl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ RUN apt-get update -y && \
RUN cd /tmp && \
curl -LO https://github.com/github/hub/releases/download/v2.11.2/hub-linux-amd64-2.11.2.tgz && \
tar -xvf hub-linux-amd64-2.11.2.tgz && \
cp hub-linux-amd64-2.11.2/bin/hub /usr/local/hub
cp hub-linux-amd64-2.11.2/bin/hub /usr/local/hub

# Add Kustomize so we can hydrate manifests
#
# TODO(jlewi): Should we create a separate image for Kustomize?
RUN cd /tmp && \
curl -LO https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.6.1/kustomize_v3.6.1_linux_amd64.tar.gz && \
tar -xvf kustomize_v3.6.1_linux_amd64.tar.gz && \
cp kustomize /usr/local/bin/kustomize && \
chmod a+x /usr/local/bin/kustomize

# TODO(jlewi): We would really like to use a distroless images but we need to shell out to
# git. I tried running git on a base-debian10 distrolless but that was missing some of the
Expand All @@ -45,23 +54,19 @@ FROM alpine:3.11

WORKDIR /

# Without ca-certificates we will get SSL errors with git
# Without openssh we will get SSL errors with git.
# Include make because we often wrap commands in make.
# bash is needed so we can run tekton scripts
RUN set -ex \
&& apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends \
git \
ca-certificates \
&& apt-get clean \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/man \
/usr/share/doc \
/usr/share/doc-base
&& apk update \
&& apk upgrade \
&& apk add --no-cache git bash openssh make \
&& rm -rf /var/lib/apt/lists/* \
&& rm /var/cache/apk/*

# Install the hub CLI for git
COPY --from=hub_builder /usr/local/hub /usr/local/bin/
COPY --from=hub_builder /usr/local/bin/kustomize /usr/local/bin/
COPY --from=builder /workspace/prctl /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/prctl"]
Loading

0 comments on commit 0e522ee

Please sign in to comment.