Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
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"]
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
target
Dockerfile
.dockerignore
166 changes: 7 additions & 159 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
uuid = { version = "1", features = ["v4", "serde"] }
chrono = { version = "0.4", features = ["serde"] }
sea-orm = { version = "1.1.19", features = ["sqlx-mysql", "runtime-tokio-rustls", "macros", "debug-print"] }
sea-orm = { version = "1.1.19", features = ["sqlx-mysql", "runtime-tokio-rustls", "macros"] }
sea-orm-migration = "1.1.19"
dotenvy = "0.15"
thiserror = "2.0.17"
anyhow = "1"
validator = "0.20.0"
jsonwebtoken = { version = "10.2.0", features = ["rust_crypto"] }
hex = "0.4.3"
sha2 = "0.10.9"
futures = "0.3.31"
ulid = "1.2.1"
serde_with = "3.15.1"
tracing-subscriber = "0.3.20"
tracing = "0.1.41"
bitflags = "2.10.0"
utoipa = { version = "5", features = ["axum_extras", "chrono", "uuid"] }

tower-http = { version = "0.6", features = ["cors"] }
tower = "0.4"

[profile.release]
lto = false
codegen-units = 16
opt-level = 2

[profile.dev]
opt-level = 0
debug = 0
28 changes: 20 additions & 8 deletions Dockerfile
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 . .
Copy link

Copilot AI Jan 31, 2026

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 potentially target/ 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.

Suggested change
COPY . .
COPY src ./src

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これはぐうの音も出ないから対応した

RUN touch src/main.rs
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RUN touch src/main.rs updates the file timestamp on every build, which makes this layer (and everything after it) effectively uncacheable and reduces build reproducibility. Removing this line (or replacing it with a deterministic cache-busting strategy only when needed) will preserve Docker layer caching and speed up builds.

Suggested change
RUN touch src/main.rs

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これわざと


COPY --from=builder /usr/src/app/target/release/UniQUE-API .
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) && \
cp target/release/UniQUE-API /usr/local/bin/

FROM alpine:latest
Copy link

Copilot AI Jan 31, 2026

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.

Copilot uses AI. Check for mistakes.
WORKDIR /root/
COPY --from=builder /usr/local/bin/UniQUE-API .
CMD ["./UniQUE-API"]