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

[v2] Consolidate go.mod #686

Merged
merged 8 commits into from
Sep 26, 2024
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
10 changes: 7 additions & 3 deletions operator/.dockerignore → .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
*.txt
*.out
*.yaml
*.yml
*_test.go
.dockerignore
.gitignore
/bin
/config
/examples
.git
bin
config
examples
deploy
hack
Dockerfile
Makefile
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dockers:
goarch: amd64

# Path to the Dockerfile (from the project root).
dockerfile: operator/Dockerfile
dockerfile: Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that goreleaser doesn't provide the necessary context or VERSION parameter for our Dockerfile, so this is probably not working.

Copy link
Contributor Author

@blampe blampe Sep 26, 2024

Choose a reason for hiding this comment

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

Yeah I also realized we're skipping the docker step during the dry run? Oh well not a big deal since we'll be getting rid of this anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should remove the dockers section of the goreleaser if it isn't expected to work.


# Templates of the Docker image names.
image_templates:
Expand Down
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Build a base image with modules cached.
FROM --platform=${BUILDPLATFORM} golang:1.23 AS base

COPY /go.mod go.mod
COPY /go.sum go.sum

ENV GOCACHE=/root/.cache/go-build
ENV GOMODCACHE=/go/pkg/mod
RUN --mount=type=cache,target=${GOMODCACHE} \
go mod download

# Build the operator.
FROM --platform=${BUILDPLATFORM} base AS op-builder
ARG TARGETOS
ARG TARGETARCH

ARG VERSION
RUN --mount=type=cache,target=${GOCACHE} \
--mount=type=cache,target=${GOMODCACHE} \
--mount=type=bind,source=/agent,target=./agent \
--mount=type=bind,source=/operator,target=./operator \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
go build -a -o /manager -ldflags="-X github.com/pulumi/pulumi-kubernetes-operator/v2/operator/version.Version=${VERSION}" ./operator/cmd/main.go

# Build the agent.
FROM --platform=${BUILDPLATFORM} base AS agent-builder
ARG TARGETOS
ARG TARGETARCH

ARG VERSION
RUN --mount=type=cache,target=${GOCACHE} \
--mount=type=cache,target=${GOMODCACHE} \
--mount=type=bind,source=/agent,target=./agent \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
go build -a -o /agent -ldflags "-X github.com/pulumi/pulumi-kubernetes-operator/v2/agent/version.Version=${VERSION}" ./agent/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static-debian12:debug-nonroot
COPY --from=op-builder /manager /manager
COPY --from=agent-builder /agent /agent
USER 65532:65532

ENTRYPOINT ["/manager"]
4 changes: 2 additions & 2 deletions agent/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"path/filepath"
"syscall"

"github.com/pulumi/pulumi-kubernetes-operator/agent/pkg/server"
"github.com/pulumi/pulumi-kubernetes-operator/agent/version"
"github.com/pulumi/pulumi-kubernetes-operator/v2/agent/pkg/server"
"github.com/pulumi/pulumi-kubernetes-operator/v2/agent/version"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/spf13/cobra"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion agent/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
package cmd

import (
"github.com/pulumi/pulumi-kubernetes-operator/agent/version"
"github.com/pulumi/pulumi-kubernetes-operator/v2/agent/version"
"github.com/spf13/cobra"
)

Expand Down
119 changes: 0 additions & 119 deletions agent/go.mod

This file was deleted.

Loading