Skip to content

Commit 78fcf32

Browse files
authored
improve docker build time + arbitrary non root uuid (#7440)
1 parent 15a4b26 commit 78fcf32

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

Dockerfile

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,35 @@ ENV GO_PATH=/usr/local/go/bin/go
192192
# Install UV
193193
RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.6.2/uv-installer.sh | sh && mv /root/.local/bin/uv /usr/local/bin/uv
194194

195-
# Preinstall python runtimes
196-
RUN uv python install 3.11
197-
RUN uv python install $LATEST_STABLE_PY
198-
199-
RUN uv venv
195+
# Preinstall python runtimes to temp build location (will copy with world-writable perms later)
196+
RUN UV_CACHE_DIR=/tmp/build_cache/uv UV_PYTHON_INSTALL_DIR=/tmp/build_cache/py_runtime uv python install 3.11
197+
RUN UV_CACHE_DIR=/tmp/build_cache/uv UV_PYTHON_INSTALL_DIR=/tmp/build_cache/py_runtime uv python install $LATEST_STABLE_PY
200198

201199

202200
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
203201
RUN apt-get -y update && apt-get install -y curl procps nodejs awscli && apt-get clean \
204202
&& rm -rf /var/lib/apt/lists/*
205203

206204
# go build is slower the first time it is ran, so we prewarm it in the build
207-
RUN mkdir -p /tmp/gobuildwarm && cd /tmp/gobuildwarm && go mod init gobuildwarm && printf "package foo\nimport (\"fmt\")\nfunc main() { fmt.Println(42) }" > warm.go && go mod tidy && go build -x && rm -rf /tmp/gobuildwarm
205+
# export ensures GOCACHE applies to all commands in the chain (not just the first)
206+
RUN export GOCACHE=/tmp/build_cache/go && mkdir -p /tmp/gobuildwarm && cd /tmp/gobuildwarm && go mod init gobuildwarm && printf "package foo\nimport (\"fmt\")\nfunc main() { fmt.Println(42) }" > warm.go && go mod tidy && go build -x && rm -rf /tmp/gobuildwarm
207+
208+
# Copy build caches to final location, then add write permissions for any UID
209+
# chmod a+rw adds read+write WITHOUT removing execute bits (755->777, 644->666)
210+
# Note: uv python install only creates py_runtime, not uv cache - we create uv/go dirs for runtime
211+
RUN mkdir -p /tmp/windmill/cache && \
212+
cp -r /tmp/build_cache/* /tmp/windmill/cache/ && \
213+
chmod -R a+rw /tmp/windmill/cache && \
214+
rm -rf /tmp/build_cache && \
215+
mkdir -p -m 777 /tmp/windmill/cache/uv /tmp/windmill/cache/go
216+
217+
# Runtime cache locations
218+
ENV UV_CACHE_DIR=/tmp/windmill/cache/uv
219+
ENV UV_PYTHON_INSTALL_DIR=/tmp/windmill/cache/py_runtime
220+
ENV GOCACHE=/tmp/windmill/cache/go
221+
222+
# Set HOME for arbitrary UID support (matches windmill's default fallback)
223+
ENV HOME=/tmp
208224

209225
ENV TZ=Etc/UTC
210226

@@ -232,23 +248,20 @@ RUN ln -s ${APP}/windmill /usr/local/bin/windmill
232248

233249
COPY ./frontend/src/lib/hubPaths.json ${APP}/hubPaths.json
234250

235-
RUN windmill cache ${APP}/hubPaths.json && rm ${APP}/hubPaths.json && chmod -R 777 /tmp/windmill
251+
RUN windmill cache ${APP}/hubPaths.json && rm ${APP}/hubPaths.json
236252

237253

238254

239-
# Cr,.eate a non-root user 'windmill' with UID and GID 1000
255+
# Create a non-root user 'windmill' with UID and GID 1000
240256
RUN addgroup --gid 1000 windmill && \
241257
adduser --disabled-password --gecos "" --uid 1000 --gid 1000 windmill
242258

243-
RUN cp -r /root/.cache /home/windmill/.cache
244-
245-
RUN mkdir -p /tmp/windmill/logs && \
246-
mkdir -p /tmp/windmill/search
259+
# /tmp/.cache may be created by earlier build steps with 755; chmod ensures any UID can write
260+
RUN mkdir -p -m 777 /tmp/windmill/logs /tmp/windmill/search /tmp/.cache && chmod 777 /tmp/.cache
247261

248-
# Make directories world-readable and writable
249-
RUN chmod -R 777 ${APP} && \
250-
chmod -R 777 /tmp/windmill && \
251-
chmod -R 777 /home/windmill/.cache
262+
# Make directories world-accessible for any UID
263+
# (cache files already have 666 from umask copy above, cache_nomount is read-only)
264+
RUN find ${APP} /tmp/windmill -type d -exec chmod 777 {} +
252265

253266
USER root
254267

0 commit comments

Comments
 (0)