Skip to content
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
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ARG BASE_IMAGE
ARG BUILDER_IMAGE
ARG BASE_IMAGE=gcr.io/distroless/static:nonroot
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We use makefile in our project, use Dockerfile directly is not a recommended way, and we don't want to spread the configurations across the project, for example, once the golang version changes, we only need to update the Makefile, which makes more sense to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So let's not pass the args to the Dockerfile at all. Default it in the Makefile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to the official documentation, it is recommended to set a default value in Dockerfile. Otherwise there will be warning messages.
https://docs.docker.com/reference/build-checks/invalid-default-arg-in-from/#examples

once the golang version changes, we only need to update the Makefile

This is just the default values which only take effect when these parameter is not provided. I think we still could only need to update Makefile in this scenario.

ARG BUILDER_IMAGE=golang:1.23.0

# Build the manager binary
FROM ${BUILDER_IMAGE} as builder
ARG TARGETOS
ARG TARGETARCH
FROM ${BUILDER_IMAGE} AS builder
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG CGO_ENABLED=0

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -25,7 +26,7 @@ COPY client-go/ client-go/
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.loader
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM python:3.10-alpine as builder
FROM python:3.10-alpine AS builder

WORKDIR /workspace

COPY pyproject.toml poetry.lock ./
ENV POETRY_VIRTUALENVS_CREATE false
ENV POETRY_VIRTUALENVS_CREATE=false

RUN apk add --no-cache \
build-base \
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GIT_TAG ?= $(shell git describe --tags --dirty --always)
IMG ?= $(IMAGE_REPO):$(GIT_TAG)
BUILDER_IMAGE ?= golang:$(GO_VERSION)
KIND_CLUSTER_NAME ?= kind
CGO_ENABLED ?= 0

LOADER_IMAGE_TAG ?= $(GIT_TAG)
LOADER_IMAGE_REPO = inftyai/model-loader
Expand Down