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

Use common base image #187

Merged
merged 2 commits into from
Nov 9, 2023
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
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignored:
- DL3006
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

# BASEIMAGE is a base image for final COSI-Driver container.
ARG BASEIMAGE
# DIGEST is a hash-version of a used BASEIMAGE.
ARG DIGEST
# GOVERSION is a Go version used for bulding driver.
ARG GOVERSION

Expand Down Expand Up @@ -42,7 +40,7 @@ COPY pkg/ pkg/
RUN make build

# Second stage: building final environment for running the driver.
FROM ${BASEIMAGE}@${DIGEST} AS final
FROM ${BASEIMAGE} AS final

WORKDIR /dell

Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,22 @@ build: ##build project
########################################################################

.PHONY: docker
docker: vendor ##build the docker container
@echo "Base Images is set to: $(BASEIMAGE)"
docker: vendor download-csm-common ##build the docker container
$(eval include csm-common.mk)
@echo "Base Images is set to: $(DEFAULT_BASEIMAGE)"
@echo "Building: $(IMAGENAME):$(IMAGETAG)"
docker build --pull -t "$(IMAGENAME):$(IMAGETAG)" --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg GOVERSION=$(GOVERSION) --build-arg DIGEST=$(DIGEST) .
docker build --pull -t "$(IMAGENAME):$(IMAGETAG)" --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) --build-arg GOVERSION=$(GOVERSION) .

.PHONY: push
push: docker ##build and push the docker container to repository
@echo "Pushing: $(REGISTRY)/$(IMAGENAME):$(IMAGETAG)"
docker tag "$(IMAGENAME):$(IMAGETAG)" "$(REGISTRY)/$(IMAGENAME):$(IMAGETAG)"
docker push "$(REGISTRY)/$(IMAGENAME):$(IMAGETAG)"

.PHONY: download-csm-common
download-csm-common:
curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk

########################################################################
## TESTING ##
########################################################################
Expand Down
20 changes: 1 addition & 19 deletions overrides.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@

# overrides.mk file
# This file, included from the Makefile, will overlay default values with environment variables:
# BASEIMAGE, DIGEST, GOVERSION, REGISTRY, IMAGENAME, IMAGETAG.
# GOVERSION, REGISTRY, IMAGENAME, IMAGETAG.

# DEFAULT values
# Image from https://catalog.redhat.com/software/containers/ubi9/ubi-micro/615bdf943f6014fa45ae1b58
DEFAULT_BASEIMAGE=registry.access.redhat.com/ubi9/ubi-micro
# DIGEST is the digest for version 9.2-13 of ubi-micro.
DEFAULT_DIGEST=sha256:630cf7bdef807f048cadfe7180d6c27eb3aaa99323ffc3628811da230ed3322a
# GOVERSION is a build version for driver.
DEFAULT_GOVERSION:=$(shell sed -En 's/^go (.*)$$/\1/p' go.mod)
# REGISTRY in which COSI image resides.
Expand All @@ -28,16 +24,6 @@ DEFAULT_IMAGENAME=dell/cosi
# IMAGETAG by default is latest commit SHA.
DEFAULT_IMAGETAG:=$(shell git rev-parse HEAD)

# set the BASEIMAGE if needed
ifeq ($(BASEIMAGE),)
export BASEIMAGE="$(DEFAULT_BASEIMAGE)"
endif

# set the IMAGEDIGEST if needed
ifeq ($(DIGEST),)
export DIGEST="$(DEFAULT_DIGEST)"
endif

# set the GOVERSION if needed
ifeq ($(GOVERSION),)
export GOVERSION="$(DEFAULT_GOVERSION)"
Expand Down Expand Up @@ -65,10 +51,6 @@ overrides-help:
@echo
@echo "GOVERSION - The version of Go to build with, default is: $(DEFAULT_GOVERSION)"
@echo " Current setting is: $(GOVERSION)"
@echo "BASEIMAGE - The base container image to build from, default is: $(DEFAULT_BASEIMAGE)"
@echo " Current setting is: $(BASEIMAGE)"
@echo "IMAGEDIGEST - The digest of baseimage, default is: $(DEFAULT_DIGEST)"
@echo " Current setting is: $(DIGEST)"
@echo "REGISTRY - The registry to push images to, default is: $(DEFAULT_REGISTRY)"
@echo " Current setting is: $(REGISTRY)"
@echo "IMAGENAME - The image name to be built, defaut is: $(DEFAULT_IMAGENAME)"
Expand Down