diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e63343f2e8..7a864fc303 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,8 @@ "moby": "true" } }, + "remoteUser": "root", "postCreateCommand": "go version", - "postAttachCommand": "sudo ln -s $(pwd)/cmd/agent/core/ngt/sample.yaml /etc/server/config.yaml", + "postAttachCommand": "mkdir -p /etc/server && ln -s $(pwd)/cmd/agent/core/ngt/sample.yaml /etc/server/config.yaml", "appPort": "3000:3000" } diff --git a/Makefile.d/tools.mk b/Makefile.d/tools.mk index ed71eaf1a1..bebd846f3b 100644 --- a/Makefile.d/tools.mk +++ b/Makefile.d/tools.mk @@ -92,3 +92,15 @@ $(BINDIR)/buf: "https://github.com/bufbuild/buf/releases/download/$(BUF_VERSION)/buf-$(shell uname -s)-$(shell uname -m)" \ -o "${BINDIR}/buf" && \ chmod +x "${BINDIR}/buf" + +.PHONY: k9s/install +k9s/install: $(GOPATH)/bin/k9s + +$(GOPATH)/bin/k9s: + $(call go-install, github.com/derailed/k9s) + +.PHONY: stern/install +stern/install: $(GOPATH)/bin/stern + +$(GOPATH)/bin/stern: + $(call go-install, github.com/stern/stern) diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index bd761f5c5b..2ee838e6d3 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -44,12 +44,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* WORKDIR ${GOPATH}/src/github.com/vdaas/vald - COPY Makefile . COPY Makefile.d Makefile.d COPY versions versions +COPY hack/go.mod.default hack/go.mod.default -RUN make ngt/install \ +# basic deps +RUN make deps \ + && make ngt/install \ && make helm/install \ && make helm-docs/install \ && make valdcli/install \ @@ -57,18 +59,9 @@ RUN make ngt/install \ && make golangci-lint/install \ && make reviewdog/install \ && make protobuf/install \ - && make kubectl/install \ - && make k3d/install - -# change GOPATH owner to vscode to run commands as user vscode without root permission -RUN chown -R vscode:vscode "${GOPATH}" \ - # mkdir for agent configuration install - && mkdir -p /etc/server - -# k9s installs the binary to the current user which is root for devcontainer -# so change the current user to vscode to user afterwards -USER vscode -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN curl -sS https://webinstall.dev/k9s | bash + && make kubectl/install -RUN go install github.com/stern/stern@latest +# additional deps +RUN make k3d/install \ + && make buf/install \ + && make k9s/install