-
Notifications
You must be signed in to change notification settings - Fork 0
ビルド時間の短縮 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ビルド時間の短縮 #21
Changes from all commits
b18b94e
79ff353
c6de0b3
14f1ef5
88ecc51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| [target.x86_64-unknown-linux-musl] | ||
| linker = "clang" | ||
| rustflags = ["-C", "link-arg=-fuse-ld=mold"] | ||
|
|
||
| [target.aarch64-unknown-linux-musl] | ||
| linker = "clang" | ||
| rustflags = ["-C", "link-arg=-fuse-ld=mold"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .git | ||
| target | ||
| Dockerfile | ||
| .dockerignore |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,19 +1,31 @@ | ||||
| FROM rust:1-alpine AS builder | ||||
|
|
||||
| WORKDIR /usr/src/app | ||||
| RUN apk add --no-cache musl-dev mold clang build-base | ||||
|
|
||||
| COPY . . | ||||
| WORKDIR /usr/src/app | ||||
|
|
||||
| RUN apk add --no-cache musl-dev mold clang build-base | ||||
| COPY .cargo .cargo | ||||
| COPY Cargo.toml Cargo.lock ./ | ||||
|
|
||||
| RUN cargo fix --bin "UniQUE-API" | ||||
| RUN mkdir src && echo "fn main() {}" > src/main.rs | ||||
|
|
||||
| RUN cargo build --release | ||||
| RUN --mount=type=cache,target=/root/.cargo/registry \ | ||||
| --mount=type=cache,target=/root/.cargo/git \ | ||||
| --mount=type=cache,target=/usr/src/app/target \ | ||||
| cargo build --release -j $(nproc) | ||||
|
|
||||
| FROM alpine:latest | ||||
| RUN rm -rf src | ||||
|
|
||||
| WORKDIR /root/ | ||||
| COPY . . | ||||
| RUN touch src/main.rs | ||||
|
||||
| RUN touch src/main.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これわざと
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime stage uses FROM alpine:latest, which pins your base image to a mutable latest tag on Docker Hub; if that tag is ever compromised or updated with a malicious or vulnerable image, every build using this Dockerfile can silently inherit the compromise. To make builds deterministic and reduce supply-chain risk, pin the base image to an immutable reference such as a specific version tag or image digest under your control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
COPY . .will send the entire build context into the image. Since the repo has no.dockerignore, it will also include directories like.git/(and potentiallytarget/after local builds), which slows builds and can invalidate cache unexpectedly. Consider adding a.dockerignore(or narrowing what gets copied) to keep the build context small and caching effective.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これはぐうの音も出ないから対応した