我正在浏览Docker Docs Guides/Language-specific guides/Rust/Develop your app在步骤Docker build中使用给定的命令,从克隆的git sample app的目录中。下面是我正在执行的构建命令-docker build -t rust-backend-image .
,由于这些错误,它无法构建。
Compiling react-rust-postgres v0.1.0 (/app)
0.358 error: couldn't read src/../migrations/0001_create-users_up.sql: No such file or directory (os error 2)
0.358 --> src/postgres.rs:8:9
0.358 |
0.358 8 | include_str!("../migrations/0001_create-users_up.sql"),
0.358 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.358 |
0.358 = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
0.358
0.358 error: couldn't read src/../migrations/0002_add-root-user-to-users_up.sql: No such file or directory (os error 2)
0.358 --> src/postgres.rs:12:9
0.358 |
0.358 12 | include_str!("../migrations/0002_add-root-user-to-users_up.sql"),
0.358 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.358 |
0.358 = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
0.358
0.421 error: could not compile `react-rust-postgres` (bin "react-rust-postgres") due to 2 previous errors
------
Dockerfile:23
字符串
我已经按照指示把所有东西都拉下来了。我最近做了一个rustup update
。MacBook Pro pre M1芯片我确实试图通过删除其中一个点来编辑include_str
,但无济于事。我不知道为什么它没有找到这些文件,因为我可以从终端使用相同的相对路径。我做错了什么?
1条答案
按热度按时间nhaq1z211#
在Dockerfile中的
--mount=type=bind,source=src,target=src \
之后添加行--mount=type=bind,source=migrations,target=migrations \
。灵感来自kmdreko的评论。