Skip to content

Commit

Permalink
Use go base image (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
panigs7 committed Feb 21, 2024
1 parent 914ab3e commit e6e6402
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
run: |
git config --global url."https://csmbot:$TOKEN@github.com".insteadOf "https://github.com"
echo "machine github.com login csmbot password $TOKEN" >> ~/.netrc
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
cache: false
- name: Checkout the code
uses: actions/checkout@v4.1.0
Expand Down Expand Up @@ -87,9 +87,9 @@ jobs:
uses: Difegue/action-perlcritic@master
with:
args: ./scripts/*
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
cache: false
- name: Install and run Checkmake
run: |
Expand Down Expand Up @@ -131,9 +131,9 @@ jobs:
run: |
git config --global url."https://csmbot:$TOKEN@github.com".insteadOf "https://github.com"
echo "machine github.com login csmbot password $TOKEN" >> ~/.netrc
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
cache: false
- name: Checkout the code
uses: actions/checkout@v4.1.0
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ run:

# Define the Go version limit.
# Mainly related to generics support since go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18
# Default: use Go version from the go.mod file, fallback on the env var `GOIMAGE`, fallback on 1.18
# Intentionally left empty to use go.mod's Go version
go: ""

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

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

# First stage: building binary of the driver.
FROM golang:${GOVERSION} as builder
FROM $GOIMAGE as builder

WORKDIR /workspace

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ 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=$(DEFAULT_BASEIMAGE) --build-arg GOVERSION=$(GOVERSION) .
docker build --pull -t "$(IMAGENAME):$(IMAGETAG)" --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) .

.PHONY: push
push: docker ##build and push the docker container to repository
Expand Down
16 changes: 8 additions & 8 deletions overrides.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

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

# DEFAULT values
# GOVERSION is a build version for driver.
DEFAULT_GOVERSION:=$(shell sed -En 's/^go (.*)$$/\1/p' go.mod)
# GOIMAGE is the version of Go.
DEFAULT_GOIMAGE:=$(shell sed -En 's/^go (.*)$$/\1/p' go.mod)
# REGISTRY in which COSI image resides.
DEFAULT_REGISTRY=docker.io
# IMAGENAME is COSI image name.
DEFAULT_IMAGENAME=dell/cosi
# IMAGETAG by default is latest commit SHA.
DEFAULT_IMAGETAG:=$(shell git rev-parse HEAD)

# set the GOVERSION if needed
ifeq ($(GOVERSION),)
export GOVERSION="$(DEFAULT_GOVERSION)"
# set the GOIMAGE if needed
ifeq ($(GOIMAGE),)
export GOIMAGE="$(DEFAULT_GOIMAGE)"
endif

# set the REGISTRY if needed
Expand All @@ -49,8 +49,8 @@ overrides-help:
@echo
@echo "The following environment variables can be set to control the build"
@echo
@echo "GOVERSION - The version of Go to build with, default is: $(DEFAULT_GOVERSION)"
@echo " Current setting is: $(GOVERSION)"
@echo "GOIMAGE - The version of Go to build with, default is: $(DEFAULT_GOIMAGE)"
@echo " Current setting is: $(GOIMAGE)"
@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

0 comments on commit e6e6402

Please sign in to comment.