fix: make migration checksums reproducible
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
237899745
2026-07-25 21:52:20 +08:00
parent b67275b3e8
commit 500a8f7ecd
3 changed files with 10 additions and 1 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
migrations/*.sql text eol=crlf

3
build.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
println!("cargo:rerun-if-changed=migrations");
}

View File

@@ -17,11 +17,16 @@ RUN sed -i "s|http://deb.debian.org/debian|${DEBIAN_MIRROR%/}|g" /etc/apt/source
&& rm -rf /var/lib/apt/lists/*
COPY Cargo.toml Cargo.lock ./
COPY build.rs ./
COPY .cargo ./.cargo
COPY src ./src
COPY migrations ./migrations
COPY templates ./templates
# SQLx hashes migration bytes at compile time. Production was initialized from
# CRLF migrations, so make every build reproduce those historical checksums.
RUN sed -i 's/\r$//; s/$/\r/' migrations/*.sql
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/app/target,sharing=locked \
if [ -n "$CARGO_REGISTRY_MIRROR" ]; then \
@@ -58,7 +63,7 @@ WORKDIR /app
COPY --from=builder /app/imageforge ./imageforge
COPY --from=frontend-builder /app/frontend/dist ./static
COPY migrations ./migrations
COPY --from=builder /app/migrations ./migrations
RUN mkdir -p uploads \
&& chown imageforge:imageforge uploads