鉴于:我想构建一个 Dockerfile 来编译 Scala 应用程序。为了加速构建,我希望缓存依赖项下载。
问题:由于./sbt -sbt-dir ./sbt-dir -ivy ./ivy update某种原因,该命令没有被缓存。
FROM openjdk:8 as workspace
ARG BUILD_VERSION
WORKDIR /build
COPY ./sbt ./sbt
COPY ./sbt-dist ./sbt-dist
COPY ./build.sbt ./build.sbt
COPY ./project/build.properties ./project/build.properties
COPY ./project/plugins.sbt ./project/plugins.sbt
RUN ./sbt -sbt-dir ./sbt-dir -ivy ./ivy update
COPY ./ ./
# Embedded postgres need to be run as non-root user
RUN useradd -ms /bin/bash runner
RUN chown -R runner /build
USER runner
RUN ./sbt -sbt-dir ./sbt-dir -ivy ./ivy clean test
RUN ./sbt …Run Code Online (Sandbox Code Playgroud) 另一个 React 18 严格模式问题。我知道 React 将调用渲染和效果函数两次,以突出即将推出的功能中潜在的内存泄漏。我还不明白的是如何正确处理这个问题。我的问题是,我无法正确卸载第一个渲染结果,因为两个 useEffect 调用是使用第二个渲染的状态执行的。这是一个例子来展示我的意思。
const ref = useRef(9);
const id = useId();
console.log('@@ initial id', id);
console.log('@@ initial ref', ref.current);
ref.current = Math.random();
console.log('@@ random ref', ref.current);
useEffect(() => {
console.log('@@ effect id', id);
console.log('@@ effect ref', ref.current);
return () => {
console.log('@@ unmount id', id);
console.log('@@ unmount ref', ref.current);
};
});
Run Code Online (Sandbox Code Playgroud)
这是日志输出
@@ initial id :r0:
@@ initial ref 9
@@ random ref 0.26890444169781214
@@ initial id :r1:
@@ initial ref 9
@@ random ref …Run Code Online (Sandbox Code Playgroud)