Skip to content

GOPATH incorrectly set to Go installation directory in Dockerfile.ubi9 #30

Description

@kaovilai

Issue Description

The current Dockerfile.ubi9 has an incorrect GOPATH configuration that violates Go's environment variable conventions.

Current Problem

In Dockerfile.ubi9:32, GOPATH is set to /opt/app-root/src/go:

ENV GOPATH /opt/app-root/src/go

However, this is the same directory where the Go installation itself is placed (line 22):

mv /go /opt/app-root/src/go

Why This is Problematic

According to Go documentation (https://go.dev/wiki/InstallTroubleshooting#environment-variables):

  • GOROOT should point to the Go installation directory
  • GOPATH should point to the workspace directory
  • GOPATH should NOT be set to, or contain, the GOROOT directory

The current setup violates this by setting GOPATH to the same location as the Go binaries.

Proposed Solution

Set the environment variables correctly:

ENV GOROOT /opt/app-root/src/go
ENV GOPATH /opt/app-root/src/workspace

This separates the Go installation (GOROOT) from the workspace (GOPATH) as intended by Go's design.

Impact

This could potentially cause issues with Go module resolution and workspace management in containers built from this image.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions