Skip to content

Commit c843a03

Browse files
authored
feat: remove linting/gen from dockerfile (#1334)
* feat: remove linting/gen from dockerfile Signed-off-by: Alessio Pragliola <[email protected]> * fix: missing checkout in action Signed-off-by: Alessio Pragliola <[email protected]> * fix: change prepare step Signed-off-by: Alessio Pragliola <[email protected]> * feat: make test target atomic Signed-off-by: Alessio Pragliola <[email protected]> * feat: make the jobs depend on prepare Signed-off-by: Alessio Pragliola <[email protected]> --------- Signed-off-by: Alessio Pragliola <[email protected]>
1 parent 36ba2cc commit c843a03

File tree

5 files changed

+37
-53
lines changed

5 files changed

+37
-53
lines changed

.github/workflows/build-and-push-image.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ env:
2121
DOCKER_USER: ${{ github.actor }}
2222
DOCKER_PWD: ${{ secrets.GITHUB_TOKEN }}
2323
jobs:
24+
prepare:
25+
uses: ./.github/workflows/prepare.yml
2426
build-image:
2527
runs-on: ubuntu-latest
28+
needs: prepare
2629
steps:
2730
# Assign context variable for various action contexts (tag, main, CI)
2831
- name: Assigning tag context
@@ -44,6 +47,7 @@ jobs:
4447
if: env.BUILD_CONTEXT == 'tag'
4548
run: |
4649
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
50+
- uses: ./.github/workflows/prepare.yml
4751
- name: Build and Push Image
4852
shell: bash
4953
run: ./scripts/build_deploy.sh

.github/workflows/build.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,19 @@ on:
1414
- ".github/dependabot.yml"
1515
- "docs/**"
1616
jobs:
17+
prepare:
18+
uses: ./.github/workflows/prepare.yml
1719
build:
20+
needs: prepare
1821
runs-on: ubuntu-latest
1922
steps:
20-
- uses: actions/checkout@v4
23+
- name: Checkout
24+
uses: actions/checkout@v4
2125
- name: Setup Go
2226
uses: actions/setup-go@v5
2327
with:
2428
go-version: "1.24"
25-
- name: Set up Python
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: 3.9
2929
- name: Build
30-
run: make clean build
31-
- name: Check if there are uncommitted file changes
32-
run: |
33-
clean=$(git status --porcelain)
34-
if [[ -z "$clean" ]]; then
35-
echo "Empty git status --porcelain: $clean"
36-
else
37-
echo "Uncommitted file changes detected: $clean"
38-
git diff
39-
exit 1
40-
fi
30+
run: make build/compile
4131
- name: Unit tests
4232
run: make test-cover

.github/workflows/prepare.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
workflow_call
3+
4+
jobs:
5+
prepare:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- name: Setup Go
10+
uses: actions/setup-go@v5
11+
with:
12+
go-version: "1.24"
13+
- name: Prepare
14+
run: make clean build/prepare
15+
- name: Check if there are uncommitted file changes
16+
run: |
17+
clean=$(git status --porcelain)
18+
if [[ -z "$clean" ]]; then
19+
echo "Empty git status --porcelain: $clean"
20+
else
21+
echo "Uncommitted file changes detected: $clean"
22+
git diff
23+
exit 1
24+
fi

Dockerfile

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,10 @@ COPY templates/ templates/
2222
COPY patches/ patches/
2323
COPY catalog/ catalog/
2424

25-
###### Dev stage - start ######
26-
# see: https://github.com/kubeflow/model-registry/pull/984#discussion_r2048732415
27-
28-
FROM common AS dev
29-
30-
USER root
31-
32-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o model-registry
33-
34-
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS dev-build
35-
36-
WORKDIR /
37-
COPY --from=dev /workspace/model-registry .
38-
USER 65532:65532
39-
40-
ENTRYPOINT ["/model-registry"]
41-
42-
###### Dev stage - end ######
43-
4425
FROM common AS builder
4526

4627
USER root
47-
# default NodeJS 14 is not enough for openapi-generator-cli, switch to Node JS currently supported
48-
RUN yum remove -y nodejs npm
49-
RUN yum module -y reset nodejs
50-
RUN yum module -y enable nodejs:18
51-
# install npm and java for openapi-generator-cli
52-
RUN yum install -y nodejs npm java-11-headless python3
53-
54-
RUN make deps
55-
56-
# NOTE: The two instructions below are effectively equivalent to 'make clean build'
57-
# DO NOT REMOVE THE 'build/prepare' TARGET!!!
58-
# It ensures consitent repeatable Dockerfile builds
5928

60-
# prepare the build in a separate layer
61-
RUN make clean build/prepare
62-
# compile separately to optimize multi-platform builds
6329
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} make build/compile
6430

6531
# Use distroless as minimal base image to package the model-registry binary

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ lint/csi: bin/golangci-lint
300300
${GOLANGCI_LINT} run internal/csi/...
301301

302302
.PHONY: test
303-
test: gen bin/envtest
303+
test: bin/envtest
304304
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" ${GO} test ./internal/... ./pkg/...
305305

306306
.PHONY: test-nocache
307-
test-nocache: gen bin/envtest
307+
test-nocache: bin/envtest
308308
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" ${GO} test ./internal/... ./pkg/... -count=1
309309

310310
.PHONY: test-cover
311-
test-cover: gen bin/envtest
311+
test-cover: bin/envtest
312312
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" ${GO} test ./internal/... ./pkg/... -coverprofile=coverage.txt
313313
${GO} tool cover -html=coverage.txt -o coverage.html
314314

0 commit comments

Comments
 (0)