build: support regional dependency mirrors
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
# Image tag built by docker/docker-compose.prod.yml
|
||||
IMAGEFORGE_TAG=local
|
||||
|
||||
# Optional regional mirror used only while building Debian image layers.
|
||||
DEBIAN_MIRROR=http://deb.debian.org/debian
|
||||
# Optional sparse Cargo registry mirror used only while building the API image.
|
||||
CARGO_REGISTRY_MIRROR=
|
||||
|
||||
# Public listener and URL
|
||||
IMAGEFORGE_BIND_ADDRESS=0.0.0.0
|
||||
IMAGEFORGE_PORT=8080
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
|
||||
FROM rust:1.92-trixie AS builder
|
||||
|
||||
ARG DEBIAN_MIRROR=http://deb.debian.org/debian
|
||||
ARG CARGO_REGISTRY_MIRROR=
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
RUN sed -i "s|http://deb.debian.org/debian|${DEBIAN_MIRROR%/}|g" /etc/apt/sources.list.d/debian.sources \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
cmake \
|
||||
libdav1d-dev \
|
||||
nasm \
|
||||
@@ -12,13 +17,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY .cargo ./.cargo
|
||||
COPY src ./src
|
||||
COPY migrations ./migrations
|
||||
COPY templates ./templates
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/app/target,sharing=locked \
|
||||
cargo build --release --locked \
|
||||
if [ -n "$CARGO_REGISTRY_MIRROR" ]; then \
|
||||
printf '\n[source.crates-io]\nreplace-with = "deployment-mirror"\n\n[source.deployment-mirror]\nregistry = "%s"\n' \
|
||||
"$CARGO_REGISTRY_MIRROR" >> .cargo/config.toml; \
|
||||
fi \
|
||||
&& cargo build --release --locked \
|
||||
&& cp /app/target/release/imageforge /app/imageforge
|
||||
|
||||
FROM node:22-alpine AS frontend-builder
|
||||
@@ -31,7 +41,11 @@ RUN npm run build
|
||||
|
||||
FROM debian:trixie-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ARG DEBIAN_MIRROR=http://deb.debian.org/debian
|
||||
|
||||
RUN sed -i "s|http://deb.debian.org/debian|${DEBIAN_MIRROR%/}|g" /etc/apt/sources.list.d/debian.sources \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libdav1d7 \
|
||||
|
||||
@@ -55,6 +55,9 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
args:
|
||||
DEBIAN_MIRROR: ${DEBIAN_MIRROR:-http://deb.debian.org/debian}
|
||||
CARGO_REGISTRY_MIRROR: ${CARGO_REGISTRY_MIRROR:-}
|
||||
init: true
|
||||
environment:
|
||||
<<: *imageforge-environment
|
||||
|
||||
Reference in New Issue
Block a user