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

change name from pluralctl to plrlctl #547

Merged
merged 5 commits into from
Sep 24, 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
53 changes: 43 additions & 10 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,42 @@ builds:
ldflags:
- -s
- -w
- -X "github.com/pluralsh/plural-cli/cmd/plural.Version={{.Version}}"
- -X "github.com/pluralsh/plural-cli/cmd/plural.Commit={{.Commit}}"
- -X "github.com/pluralsh/plural-cli/cmd/plural.Date={{.Date}}"
- -X "github.com/pluralsh/plural-cli/pkg/common.Version={{.Version}}"
- -X "github.com/pluralsh/plural-cli/pkg/common.Commit={{.Commit}}"
- -X "github.com/pluralsh/plural-cli/pkg/common.Date={{.Date}}"
- -X "github.com/pluralsh/plural-cli/pkg/scm.GitlabClientSecret={{.Env.GITLAB_CLIENT_SECRET}}"
binary: plural
# Do not embed UI into linux/arm64 and windows/arm64 binaries
overrides:
- goos: linux
goarch: arm64
tags: [linux]
env:
- CGO_ENABLED=0
- goos: windows
goarch: arm64
tags: [windows]
env:
- CGO_ENABLED=0
- id: plrlctl
main: ./cmd/plrlctl
targets:
- linux_amd64
- linux_arm64
- windows_amd64
# TODO: Re-enable once fixed
# Ref: https://github.com/golang/go/issues/51019
# - windows_arm64
- darwin_amd64
- darwin_arm64
env:
- CGO_ENABLED=0
ldflags:
- -s
- -w
- -X "github.com/pluralsh/plural-cli/pkg/common.Version={{.Version}}"
- -X "github.com/pluralsh/plural-cli/pkg/common.Commit={{.Commit}}"
- -X "github.com/pluralsh/plural-cli/pkg/common.Date={{.Date}}"
- -X "github.com/pluralsh/plural-cli/pkg/scm.GitlabClientSecret={{.Env.GITLAB_CLIENT_SECRET}}"
binary: plural
# Do not embed UI into linux/arm64 and windows/arm64 binaries
Expand Down Expand Up @@ -70,13 +103,13 @@ archives:
{{- title .Os }}_
{{- if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
# - id: plural-cli-console
# builds: [ plural-cli-console ]
# name_template: >-
# {{ .ProjectName }}_console_{{ .Version }}_
# {{- title .Os }}_
# {{- if eq .Arch "386" }}i386
# {{- else }}{{ .Arch }}{{ end }}
- id: plrlctl
builds: [plrlctl]
name_template: >-
{{ .ProjectName }}_{{ .Version }}_
{{- title .Os }}_
{{- if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}

checksum:
name_template: 'checksums.txt'
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.10 as user
FROM ubuntu:22.10 AS user

# Create a nonroot user for final image
RUN useradd -u 10001 nonroot
Expand Down Expand Up @@ -26,12 +26,12 @@ ARG TARGETARCH

RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
go build -ldflags '-s -w \
-X "github.com/pluralsh/plural-cli/cmd/plural.Version=${APP_VSN}" \
-X "github.com/pluralsh/plural-cli/cmd/plural.Commit=${APP_COMMIT}" \
-X "github.com/pluralsh/plural-cli/cmd/plural.Date=${APP_DATE}"' \
-X "github.com/pluralsh/plural-cli/pkg/common.Version=${APP_VSN}" \
-X "github.com/pluralsh/plural-cli/pkg/common.Commit=${APP_COMMIT}" \
-X "github.com/pluralsh/plural-cli/pkg/common.Date=${APP_DATE}"' \
-o plural ./cmd/plural

FROM golang:1.20-alpine3.17
FROM golang:1.22-alpine3.19 AS final

WORKDIR /

Expand Down
26 changes: 19 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include $(ROOT_DIRECTORY)/hack/include/build.mk

GCP_PROJECT ?= pluralsh
APP_NAME ?= plural-cli
APP_CTL_NAME ?= plrlctl
APP_VSN ?= $(shell git describe --tags --always --dirty)
APP_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
BUILD ?= $(shell git rev-parse --short HEAD)
Expand All @@ -16,17 +17,17 @@ GOLANG_CROSS_VERSION ?= v1.22.0
PACKAGE ?= github.com/pluralsh/plural
BASE_LDFLAGS ?= -s -w
LDFLAGS ?= $(BASE_LDFLAGS) $\
-X "$(PACKAGE)/cmd/plural.Version=$(APP_VSN)" $\
-X "$(PACKAGE)/cmd/plural.Commit=$(BUILD)" $\
-X "$(PACKAGE)/cmd/plural.Date=$(APP_DATE)" $\
-X "$(PACKAGE)/pkg/common.Version=$(APP_VSN)" $\
-X "$(PACKAGE)/pkg/common.Commit=$(BUILD)" $\
-X "$(PACKAGE)/pkg/common.Date=$(APP_DATE)" $\
-X "$(PACKAGE)/pkg/scm.GitlabClientSecret=${GITLAB_CLIENT_SECRET}" $\
-X "$(PACKAGE)/pkg/scm.BitbucketClientSecret=${BITBUCKET_CLIENT_SECRET}"
WAILS_TAGS ?= desktop,production,ui,debug
WAILS_BINDINGS_TAGS ?= bindings,generate
WAILS_BINDINGS_BINARY_NAME ?= wailsbindings
TAGS ?= $(WAILS_TAGS)
OUTFILE ?= plural.o
OUTCTLFILE ?= pluralctl.o
OUTCTLFILE ?= plrlctl.o
GOBIN ?= go env GOBIN

# Targets to run before other targets
Expand All @@ -41,15 +42,15 @@ git-push:
.PHONY: install
install:
go build -ldflags '$(LDFLAGS)' -o $(GOBIN)/plural ./cmd/plural
go build -ldflags '$(LDFLAGS)' -o $(GOBIN)/pluralctl ./cmd/pluralctl
go build -ldflags '$(LDFLAGS)' -o $(GOBIN)/plrlctl ./cmd/plrlctl

.PHONY: build-cli
build-cli: ## Build a CLI binary for the host architecture without embedded UI
go build -ldflags='$(LDFLAGS)' -o $(OUTFILE) ./cmd/plural

.PHONY: build-ctl
build-ctl: ## Build a CLI binary for the fleet management
go build -ldflags='$(LDFLAGS)' -o $(OUTCTLFILE) ./cmd/plural
go build -ldflags='$(LDFLAGS)' -o $(OUTCTLFILE) ./cmd/plrlctl

.PHONY: build-cli-ui
build-cli-ui: $(PRE) generate-bindings ## Build a CLI binary for the host architecture with embedded UI
Expand Down Expand Up @@ -77,7 +78,7 @@ generate-bindings: build-web ## Generate backend bindings for the embedded UI
.PHONY: release
release:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags='$(LDFLAGS)' -o $(OUTFILE) ./cmd/plural
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags='$(LDFLAGS)' -o $(OUTCTLFILE) ./cmd/pluralctl
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags='$(LDFLAGS)' -o $(OUTCTLFILE) ./cmd/plrlctl

.PHONY: goreleaser
goreleaser:
Expand All @@ -102,6 +103,17 @@ build: ## Build the Docker image
-t gcr.io/$(GCP_PROJECT)/$(APP_NAME):$(APP_VSN) \
-t $(DKR_HOST)/plural/$(APP_NAME):$(APP_VSN) .

.PHONY: build-ctl
build-ctl: ## Build the plrctl Docker image
docker build --build-arg APP_NAME=$(APP_CTL_NAME) \
--build-arg APP_VSN=$(APP_VSN) \
--build-arg APP_DATE=$(APP_DATE) \
--build-arg APP_COMMIT=$(BUILD) \
-t $(APP_CTL_NAME):$(APP_VSN) \
-t $(APP_CTL_NAME):latest \
-t gcr.io/$(GCP_PROJECT)/$(APP_CTL_NAME):$(APP_VSN) \
-t $(DKR_HOST)/plural/$(APP_CTL_NAME):$(APP_VSN) -f dockerfiles/plrlctl/Dockerfile .

.PHONY: build-cloud
build-cloud: ## build the cloud docker image
docker build --build-arg APP_NAME=$(APP_NAME) \
Expand Down
2 changes: 1 addition & 1 deletion cmd/pluralctl/main.go → cmd/plrlctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/pluralsh/plural-cli/pkg/utils"
)

const ApplicationName = "pluralctl"
const ApplicationName = "plrlctl"

type Plural struct {
client.Plural
Expand Down
47 changes: 47 additions & 0 deletions dockerfiles/plrlctl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM ubuntu:22.10 AS user

# Create a nonroot user for final image
RUN useradd -u 10001 nonroot

FROM golang:1.22-alpine3.19 AS builder

WORKDIR /workspace

# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY cmd/ cmd/
COPY pkg/ pkg/

# Build
ARG APP_VSN
ARG APP_COMMIT
ARG APP_DATE
ARG TARGETARCH

RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
go build -ldflags '-s -w \
-X "github.com/pluralsh/plural-cli/pkg/common.Version=${APP_VSN}" \
-X "github.com/pluralsh/plural-cli/pkg/common.Commit=${APP_COMMIT}" \
-X "github.com/pluralsh/plural-cli/pkg/common.Date=${APP_DATE}"' \
-o plrlctl ./cmd/plrlctl

FROM golang:1.22-alpine3.19 AS final

WORKDIR /

RUN apk update && apk add --no-cache git build-base

# Copy nonroot user and switch to it
COPY --from=user /etc/passwd /etc/passwd
USER nonroot

COPY --chown=nonroot --from=builder /workspace/plrlctl /go/bin/
RUN chmod a+x /go/bin/plrlctl

ENTRYPOINT ["/go/bin/plrlctl"]
Loading