Skip to content

Commit

Permalink
feat: support ignore tools by arg (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Jul 15, 2021
1 parent 1e32282 commit ac8abc3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,25 @@ To use a custom base image with `containerbase/buildpack` checkout [custom-base-
### Custom Root CA Certificates

To add custom root certifactes to the `containerbase/buildpack` base image checkout [custom-root-ca](./docs/custom-root-ca.md) docs.

### Temporary disable tool installer

To temporary disable / skip some tool installer set the build arg `IGNORED_TOOLS` to a comma separated case-insensitive tool names list.

The following sample will skip the installation of `powershell` and `node`.

```Dockerfile
FROM containerbase/buildpack

ARG IGNORED_TOOLS=powershell,node


# renovate: datasource=github-releases lookupName=PowerShell/PowerShell
RUN install-tool powershell v7.1.3

# renovate: datasource=docker versioning=docker
RUN install-tool node 14.17.3

# renovate: datasource=github-releases lookupName=moby/moby
RUN install-tool docker 20.10.7
```
5 changes: 5 additions & 0 deletions src/usr/local/bin/install-tool
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ if [[ ! -f "$TOOL" ]]; then
exit 1;
fi

if [[ $(ignore_tool) -eq 1 ]]; then
echo "Tool ignored - skipping: ${TOOL_NAME}"
exit 0;
fi


echo "Installing tool ${TOOL_NAME} v${TOOL_VERSION}"
. $TOOL
Expand Down
5 changes: 5 additions & 0 deletions src/usr/local/buildpack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,8 @@ function find_tool_path () {
echo ${USER_HOME}/${TOOL_NAME}/${TOOL_VERSION}
fi
}

ignore_tool() {
local tools=${IGNORED_TOOLS,,}
[[ $tools =~ (^|,)$TOOL_NAME($|,) ]] && echo 1 || echo 0
}
19 changes: 19 additions & 0 deletions test/latest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ USER ${USER_ID}
WORKDIR /tmp
RUN mkdir $HOME/.tf-cache && TF_PLUGIN_CACHE_DIR=$HOME/.tf-cache terraform init

#--------------------------------------
# test: ignore tools
#--------------------------------------
FROM build as testh

ARG APT_HTTP_PROXY

ARG IGNORED_TOOLS=powershell,node

# renovate: datasource=github-releases lookupName=PowerShell/PowerShell
RUN install-tool powershell v7.1.3

# renovate: datasource=docker versioning=docker
RUN install-tool node 14.17.3

# renovate: datasource=github-releases lookupName=moby/moby
RUN install-tool docker 20.10.7

#--------------------------------------
# final
#--------------------------------------
Expand All @@ -165,3 +183,4 @@ COPY --from=testd /.dummy /.dummy
COPY --from=teste /.dummy /.dummy
COPY --from=testf /.dummy /.dummy
COPY --from=testg /.dummy /.dummy
COPY --from=testh /.dummy /.dummy

0 comments on commit ac8abc3

Please sign in to comment.