Skip to content

Commit 1ebf7d3

Browse files
author
Phillip Wittrock
authored
Merge pull request #236 from pwittrock/brodocs
Run brodocs container as the current user.
2 parents 9fb728d + 723079a commit 1ebf7d3

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

build/thirdparty/brodocs/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Builds Docker image to run brodocs
2+
3+
FROM node:7.2
4+
MAINTAINER Phillip Wittrock <[email protected]>
5+
6+
RUN apt-get update && apt-get install -y npm git && apt-get clean && rm -rf /var/lib/apt/lists/*
7+
8+
RUN git clone --depth=1 https://github.com/Birdrock/brodocs.git
9+
WORKDIR brodocs
10+
RUN npm install
11+
12+
COPY runbrodocs.sh .
13+
14+
RUN rm -rf ./documents/*
15+
RUN chmod -R 777 .
16+
17+
CMD ["./runbrodocs.sh"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
cp /manifest/manifest.json ./manifest.json
4+
cp /source/* ./documents/
5+
node brodoc.js
6+
cp -r ./* /build/

cmd/kubebuilder/docs/docs.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"log"
2222
"os"
2323
"os/exec"
24+
"os/user"
2425
"path/filepath"
2526
"strings"
2627

@@ -157,13 +158,21 @@ func RunDocs(cmd *cobra.Command, args []string) {
157158
generatecmd.RunGenerate(cmd, args)
158159

159160
if brodocs {
161+
user, err := user.Current()
162+
if err != nil {
163+
log.Fatalf("error: %v\n", err)
164+
}
165+
160166
// Run the docker command to build the docs
161167
c = exec.Command("docker", "run",
168+
"-u", fmt.Sprintf("%s:%s", user.Uid, user.Gid),
169+
"-v", "/etc/group:/etc/group:ro",
170+
"-v", "/etc/passwd:/etc/passwd:ro",
162171
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "includes"), "/source"),
163172
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "build"), "/build"),
164173
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir, "build"), "/build"),
165174
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir), "/manifest"),
166-
"gcr.io/kubebuilder/brodocs",
175+
"gcr.io/kubebuilder/brodocs:v0.1.11",
167176
)
168177
if verbose {
169178
log.Println(strings.Join(c.Args, " "))

0 commit comments

Comments
 (0)