Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set alpine:latest as a base image by default #192

Merged
merged 4 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG BASE_IMAGE=alpine:3.14.0
FROM golang:alpine as builder

COPY . /usr/src/network-operator
Expand All @@ -23,7 +24,7 @@ RUN apk add --no-cache --virtual build-dependencies build-base linux-headers git
make clean && \
make build

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
FROM ${BASE_IMAGE}

ENV OPERATOR=/usr/local/bin/network-operator \
USER_UID=1001 \
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ lint: | $(BASE) $(GOLANGCI_LINT) ; $(info running golangci-lint...) @ ## Run go
.PHONY: lint-dockerfile
lint-dockerfile: $(HADOLINT) ; $(info running Dockerfile lint with hadolint...) @ ## Run hadolint
# DL3018 - allow installing apks without explicit version
# DL3007 - allow using "latest" tag for images
$Q $(HADOLINT) --ignore DL3018 --ignore DL3007 Dockerfile
# DL3006 - Always tag the version of an image explicitly (until https://github.com/hadolint/hadolint/issues/339 is fixed)

$Q $(HADOLINT) --ignore DL3018 --ignore DL3006 Dockerfile

.PHONY: lint-helm
lint-helm: $(HELM) ; $(info running lint for helm charts...) @ ## Run helm lint
Expand Down Expand Up @@ -181,10 +182,12 @@ test-coverage: test-coverage-tools | $(BASE) ; $(info running coverage tests...
. ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); cd $(BASE); $(GO) test -covermode=$(COVERAGE_MODE) -coverprofile=network-operator.cover ./...

# Container image
.PHONY: image
.PHONY: image ubi-image
image: | $(BASE) ; $(info Building Docker image...) @ ## Build conatiner image
$(IMAGE_BUILDER) build -t $(TAG) -f $(DOCKERFILE) $(CURDIR) $(IMAGE_BUILD_OPTS)

ubi-image: IMAGE_BUILD_OPTS += --build-arg BASE_IMAGE=registry.access.redhat.com/ubi8/ubi-minimal:8.4
ubi-image: image ## Build UBI-based container image

# Misc

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* [System Requirements](#system-requirements)
* [Compatibility Notes](#compatibility-notes)
* [Deployment Example](#deployment-example)
* [Docker image](#docker-image)
* [Driver Containers](#driver-containers)

<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
Expand Down Expand Up @@ -310,6 +311,16 @@ Example can be found under `./example/crs/mellanox.com_v1alpha1_macvlannetwork_c

A deployment example can be found under `example` folder [here](https://github.com/Mellanox/network-operator/blob/master/example/README.md).

## Docker image
Network operator uses `alpine` base image by default. To build Network operator with
another base image you need to pass `BASE_IMAGE` argument:

```
docker build -t network-operator \
--build-arg BASE_IMAGE=registry.access.redhat.com/ubi8/ubi-minimal:latest \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to add to Travis to build both type of images (not for this release)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll move it to jenkins to not hit dokerpull limit. golang image from dokcerhub is still using for base builder image

.
```

## Driver Containers
Driver containers are essentially containers that have or yield kernel modules compatible
with the underlying kernel.
Expand Down