Skip to content

Commit

Permalink
Use docker base image provide the needed dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonen committed Apr 24, 2020
1 parent ce8e631 commit e66c98d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
FROM debian:stretch-slim
FROM docker:stable
MAINTAINER Jan Boonen <[email protected]>

ARG VERSION
ENV OS "linux"
ENV BIT "64"

RUN echo "Installing curl..." && \
apt update && apt install -y curl && \
if [ x$VERSION = 'latest' ] ; then \
RUN apk add --no-cache curl

RUN VERSION=${VERSION:-latest} && \
if [ $VERSION = 'latest' ]; then \
echo "Downloading latest version of Operator SDK from Github..." && \
curl -sL https://api.github.com/repos/operator-framework/operator-sdk/releases |\
grep browser_download |\
grep $OS |\
grep ${OS} |\
cut -d '"' -f 4 |\
grep operator-sdk |\
grep x86_$BIT-$OS |\
grep x86_${BIT}-${OS} |\
grep -v .asc |\
head -n 1 |\
xargs curl -sOL; \
else \
echo "Downloading version $VERSION of Operator SDK from Github..." && \
curl -sOL "https://github.com/operator-framework/operator-sdk/releases/download/v${VERSION}/operator-sdk-v${VERSION}-x86_${BIT}-${OS}-gnu"; \
fi && \
cp ./operator-sdk-* /usr/local/bin/operator-sdk && rm -f ./operator-sdk && \
cp ./operator-sdk-* /usr/local/bin/operator-sdk && rm -f ./operator-sdk* && \
chmod a+x /usr/local/bin/operator-sdk && \
rm -rf /var/lib/apt/lists/* /tmp/* && \
mkdir -p /source

WORKDIR /source
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# operator-sdk
Run the [Kubernetes Operator SDK](https://github.com/operator-framework/operator-sdk) using Docker. This is especially useful in environments where
installing the binaries is not an option (e.g. in CI/CD pipelines).

Run the [Kubernetes Operator SDK](https://github.com/operator-framework/operator-sdk) using Docker. This is especially
useful in environments where installing the binaries is not an option (e.g. in CI/CD pipelines). The `latest` version of
this image will be the latest release of the *Operator SDK*.

## Usage
Build a custom operator using the `operator-sdk` command:

Before you start, you must have a Docker daemon running on the host machine. You can check this by using the command
`docker version`. In order to build a custom operator using the `operator-sdk` binary, use the following command:

```bash
docker run --rm -v ${PWD}:/source build operator-image:operator-version
docker run --rm -v ${PWD}:/source -v /var/run/docker.sock:/var/run/docker.sock --privileged boonen/operator-sdk:latest build operator-image:operator-version
```

This command will mount the current working directory in `/source` and build the operator based on the source code in the
working directory.

0 comments on commit e66c98d

Please sign in to comment.