Skip to content

Commit 003839f

Browse files
committed
fix: build artifacts owned by root on Linux
Fixes #175
1 parent 3d30a2a commit 003839f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

builder/builder.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ func (b *Builder) dockerBuildForLang(lang string) (*BuildResult, error) {
157157

158158
result := &BuildResult{}
159159

160-
outputLog, err := b.Config.CommandRunner.Run(fmt.Sprintf("docker run --rm --mount type=bind,source=%s,target=/root/runnable %s subo build %s --native --langs %s", b.Context.MountPath, img, b.Context.RelDockerPath, lang))
160+
// Run the Docker toolchain as the current user
161+
uid := os.Getuid()
162+
gid := os.Getgid()
163+
164+
outputLog, err := b.Config.CommandRunner.Run(fmt.Sprintf("docker run --rm --mount type=bind,source=%s,target=/usr/src/runnable -u %d:%d %s subo build %s --native --langs %s", b.Context.MountPath, uid, gid, img, b.Context.RelDockerPath, lang))
161165

162166
result.OutputLog = outputLog
163167

builder/docker/rust/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
FROM suborbital/subo:dev as subo
22

33
FROM rust:1.56.1-slim-buster
4-
WORKDIR /root/runnable
4+
WORKDIR /usr/src/runnable
55
COPY --from=subo /go/bin/subo /usr/local/bin
66

7-
# install the wasm target and then install something that
8-
# doesn't exist (and ignore the error) to update the crates.io index
9-
RUN mkdir /root/suborbital && \
10-
rustup target install wasm32-wasi
11-
RUN cargo install lazy_static; exit 0
7+
# install the wasm target and then force an update of the crates.io index
8+
RUN rustup target install wasm32-wasi && \
9+
cargo search suborbital
10+
11+
# make everything inside CARGO_HOME writable for anyone (again)
12+
RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME

0 commit comments

Comments
 (0)