diff --git a/.editorconfig b/.editorconfig index 1a78f9c75..da7d8221e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,6 @@ root = true -[*.{rs,html,js,json}] +[*.{rs,html,js,json,scss}] end_of_line = lf charset = utf-8 trim_trailing_whitespace = true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae72d5dbd..5451433d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: env: RUST_BACKTRACE: 1 - RUST_CACHE_KEY: rust-cache-20240320 + RUST_CACHE_KEY: rust-cache-20240327 DOCSRS_PREFIX: ignored/cratesfyi-prefix DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@localhost:15432 DOCSRS_LOG: docs_rs=debug,rustwide=info diff --git a/Cargo.toml b/Cargo.toml index 08500bd24..6484f147c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,8 +132,9 @@ aws-smithy-runtime = {version = "1.0.1", features = ["client", "test-util"]} aws-smithy-http = "0.60.0" indoc = "2.0.0" -[profile.dev.package.sqlx-macros] +[profile.dev.package."*"] opt-level = 2 +debug = "line-tables-only" [build-dependencies] time = "0.3" diff --git a/docker-compose.yml b/docker-compose.yml index ce503de9c..6bad85bf3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,9 @@ services: build: context: . dockerfile: ./dockerfiles/Dockerfile + args: + PROFILE: dev + PROFILE_DIR: debug platform: "linux/amd64" depends_on: - db @@ -16,6 +19,7 @@ services: - "/var/run/docker.sock:/var/run/docker.sock" - ".rustwide-docker:/opt/docsrs/rustwide" - "cratesio-index:/opt/docsrs/prefix/crates.io-index" + - "./static:/opt/docsrs/static:ro" environment: DOCSRS_RUSTWIDE_WORKSPACE: /opt/docsrs/rustwide DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@db diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 2ece0578d..f9ec2c4ad 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu:22.04 AS build # Install packaged dependencies RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ build-essential git curl cmake gcc g++ pkg-config libmagic-dev \ - libssl-dev zlib1g-dev ca-certificates + libssl-dev zlib1g-dev ca-certificates mold clang # Install the stable toolchain with rustup RUN curl https://sh.rustup.rs >/tmp/rustup-init && \ @@ -22,6 +22,11 @@ RUN curl https://sh.rustup.rs >/tmp/rustup-init && \ /tmp/rustup-init -y --no-modify-path --default-toolchain stable --profile minimal ENV PATH=/root/.cargo/bin:$PATH +# Configure linking to use mold instead for speed (need to use clang because gcc +# is too old on this image) +ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang +ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-Clink-arg=-fuse-ld=mold + # Build the dependencies in a separate step to avoid rebuilding all of them # every time the source code changes. This takes advantage of Docker's layer # caching, and it works by copying the Cargo.{toml,lock} with dummy source code @@ -36,7 +41,9 @@ RUN mkdir -p src/bin && \ echo "fn main() {}" > build.rs RUN cargo fetch -RUN cargo build --release + +ARG PROFILE=release +RUN cargo build --profile=$PROFILE # Dependencies are now cached, copy the actual source code and do another full # build. The touch on all the .rs files is needed, otherwise cargo assumes the @@ -54,7 +61,7 @@ COPY assets assets/ COPY .sqlx .sqlx/ COPY migrations migrations/ -RUN cargo build --release +RUN cargo build --profile=$PROFILE ###################### # Web server stage # @@ -69,7 +76,8 @@ RUN apt-get update \ tini \ && rm -rf /var/lib/apt/lists/* -COPY --from=build /build/target/release/cratesfyi /usr/local/bin +ARG PROFILE_DIR=release +COPY --from=build /build/target/$PROFILE_DIR/cratesfyi /usr/local/bin COPY static /srv/docsrs/static COPY templates /srv/docsrs/templates COPY vendor /srv/docsrs/vendor @@ -96,7 +104,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ RUN mkdir -p /opt/docsrs/prefix -COPY --from=build /build/target/release/cratesfyi /usr/local/bin +ARG PROFILE_DIR=release +COPY --from=build /build/target/$PROFILE_DIR/cratesfyi /usr/local/bin COPY static /opt/docsrs/static COPY templates /opt/docsrs/templates COPY dockerfiles/entrypoint.sh /opt/docsrs/