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

Fix Dockerfile Packaging Issues Related to Go Version and Missing Utils #92

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

kr11
Copy link
Collaborator

@kr11 kr11 commented Aug 26, 2024

Pull Request Description

This PR addresses two key issues encountered during the Docker build process:

Missing Package Error: The package github.com/aibrix/aibrix/pkg/utils was not found.
Inconsistency between go.mod and Dockerfile Go Version: The Dockerfile specifies Go version 1.21, whereas go.mod was updated to Go version 1.22 in PR #86.

This PR addresses two key issues encountered during the Docker build process:

  1. Missing Package Error: The package github.com/aibrix/aibrix/pkg/utils was not found.
  2. Inconsistency between go.mod and Dockerfile Go Version: The Dockerfile specifies Go version 1.21, whereas go.mod was updated to Go version 1.22 in PR #86.

Commands Executed:

make docker-build IMG=aibrix/aibrix-controller-manager:v0.1.0-rc.0
make deploy IMG=aibrix/aibrix-controller-manager:v0.1.0-rc.0

Error Output for Issue 1:

docker build -t aibrix/aibrix-controller-manager:v0.1.0-rc.0 .
[+] Building 1.2s (15/16)                                                                                                                                                                                    docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.0s
 => => transferring dockerfile: 1.31kB                                                                                                                                                                                       0.0s
 => [internal] load metadata for gcr.io/distroless/static:nonroot                                                                                                                                                            0.4s
 => [internal] load metadata for docker.io/library/golang:1.21                                                                                                                                                               0.8s
 => [internal] load .dockerignore                                                                                                                                                                                            0.0s
 => => transferring context: 160B                                                                                                                                                                                            0.0s
 => [builder 1/9] FROM docker.io/library/golang:1.21@sha256:4746d26432a9117a5f58e95cb9f954ddf0de128e9d5816886514199316e4a2fb                                                                                                 0.0s
 => [stage-1 1/3] FROM gcr.io/distroless/static:nonroot@sha256:8dd8d3ca2cf283383304fd45a5c9c74d5f2cd9da8d3b077d720e264880077c65                                                                                              0.0s
 => [internal] load build context                                                                                                                                                                                            0.0s
 => => transferring context: 2.63kB                                                                                                                                                                                          0.0s
 => CACHED [builder 2/9] WORKDIR /workspace                                                                                                                                                                                  0.0s
 => CACHED [builder 3/9] COPY go.mod go.mod                                                                                                                                                                                  0.0s
 => CACHED [builder 4/9] COPY go.sum go.sum                                                                                                                                                                                  0.0s
 => CACHED [builder 5/9] RUN go mod download                                                                                                                                                                                 0.0s
 => CACHED [builder 6/9] COPY cmd/main.go cmd/main.go                                                                                                                                                                        0.0s
 => CACHED [builder 7/9] COPY api/ api/                                                                                                                                                                                      0.0s
 => CACHED [builder 8/9] COPY pkg/controller/ pkg/controller/                                                                                                                                                                0.0s
 => ERROR [builder 9/9] RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o manager cmd/main.go                                                                                                                         0.3s
------
 > [builder 9/9] RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o manager cmd/main.go:
0.284 pkg/controller/podautoscaler/scaler/scaler.go:25:2: no required module provides package github.com/aibrix/aibrix/pkg/utils; to add it:
0.284   go get github.com/aibrix/aibrix/pkg/utils
------
Dockerfile:24
--------------------
  22 |     # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
  23 |     # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
  24 | >>> RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
  25 |     
  26 |     # Use distroless as minimal base image to package the manager binary
--------------------
ERROR: failed to solve: process "/bin/sh -c CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go" did not complete successfully: exit code: 1

Corrected Output:

make deploy IMG=aibrix/aibrix-controller-manager:v0.1.0-rc.0
docker build -t aibrix/aibrix-controller-manager:v0.1.0-rc.0 .
[+] Building 13.1s (18/18) FINISHED                                                                                                                                                                          docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.0s
 => => transferring dockerfile: 1.33kB                                                                                                                                                                                       0.0s
 => [internal] load metadata for gcr.io/distroless/static:nonroot                                                                                                                                                            0.6s
 => [internal] load metadata for docker.io/library/golang:1.22                                                                                                                                                               2.5s
 => [internal] load .dockerignore                                                                                                                                                                                            0.0s
 => => transferring context: 160B                                                                                                                                                                                            0.0s
 => [builder  1/10] FROM docker.io/library/golang:1.22@sha256:367bb5295d3103981a86a572651d8297d6973f2ec8b62f716b007860e22cbc25                                                                                               0.0s
 => CACHED [stage-1 1/3] FROM gcr.io/distroless/static:nonroot@sha256:8dd8d3ca2cf283383304fd45a5c9c74d5f2cd9da8d3b077d720e264880077c65                                                                                       0.0s
 => [internal] load build context                                                                                                                                                                                            0.0s
 => => transferring context: 46.96kB                                                                                                                                                                                         0.0s
 => CACHED [builder  2/10] WORKDIR /workspace                                                                                                                                                                                0.0s
 => CACHED [builder  3/10] COPY go.mod go.mod                                                                                                                                                                                0.0s
 => CACHED [builder  4/10] COPY go.sum go.sum                                                                                                                                                                                0.0s
 => CACHED [builder  5/10] RUN go mod download                                                                                                                                                                               0.0s
 => CACHED [builder  6/10] COPY cmd/main.go cmd/main.go                                                                                                                                                                      0.0s
 => CACHED [builder  7/10] COPY api/ api/                                                                                                                                                                                    0.0s
 => [builder  8/10] COPY pkg/controller/ pkg/controller/                                                                                                                                                                     0.0s
 => [builder  9/10] COPY pkg/utils/ pkg/utils/                                                                                                                                                                               0.0s
 => [builder 10/10] RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o manager cmd/main.go                                                                                                                            10.3s
 => [stage-1 2/3] COPY --from=builder /workspace/manager .                                                                                                                                                                   0.1s
 => exporting to image                                                                                                                                                                                                       0.1s
 => => exporting layers                                                                                                                                                                                                      0.1s
 => => writing image sha256:d6003a0a5ce42192be94232dce5fedc559c1a4fc6a08363e0996bf1c2ef38f2f                                                                                                                                 0.0s
 => => naming to docker.io/aibrix/aibrix-controller-manager:v0.1.0-rc.0    

These changes ensure that the Docker build process aligns with the updated Go version in go.mod and resolves the issue of the missing package, thereby streamlining the deployment process.


Feel free to modify the exact error messages ("xxx") with the specific output relevant to your actual issue and resolution.

Related Issues

Resolves: #[Insert issue number(s)]

Important: Before submitting, please complete the description above and review the checklist below.


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

@kr11 kr11 requested a review from Jeffwan August 26, 2024 07:57
@kr11 kr11 self-assigned this Aug 26, 2024
@kr11 kr11 added the kind/bug Something isn't working label Aug 26, 2024
@kr11 kr11 requested a review from varungup90 August 26, 2024 07:58
@@ -15,6 +15,7 @@ RUN go mod download
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY pkg/controller/ pkg/controller/
COPY pkg/utils/ pkg/utils/
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks good to me. In future, we should copy all pkg/ folder into the container.

@Jeffwan
Copy link
Collaborator

Jeffwan commented Aug 26, 2024

looks good to me

@Jeffwan Jeffwan merged commit 889eaf6 into main Aug 27, 2024
2 checks passed
@Jeffwan Jeffwan deleted the kangrong/bugs/dockerfile_error_about_utils branch August 27, 2024 05:10
gangmuk pushed a commit that referenced this pull request Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants