Skip to content
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

Add dockerfile #432

Merged
merged 14 commits into from Oct 18, 2019
2 changes: 2 additions & 0 deletions .dockerignore
@@ -0,0 +1,2 @@
/.rustwide
**/target
52 changes: 52 additions & 0 deletions Dockerfile
@@ -0,0 +1,52 @@
FROM rust:slim

### STEP 1: Install dependencies ###
# Install packaged dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git curl cmake gcc g++ pkg-config libmagic-dev \
libssl-dev zlib1g-dev sudo docker.io

### STEP 2: Create user ###
ENV HOME=/home/cratesfyi
RUN adduser --home $HOME --disabled-login --disabled-password --gecos "" cratesfyi

### STEP 3: Setup build environment as new user ###
ENV CRATESFYI_PREFIX=/home/cratesfyi/prefix
RUN mkdir $CRATESFYI_PREFIX && chown cratesfyi:cratesfyi "$CRATESFYI_PREFIX"

USER cratesfyi
RUN mkdir -vp "$CRATESFYI_PREFIX"/documentations "$CRATESFYI_PREFIX"/public_html "$CRATESFYI_PREFIX"/sources
RUN git clone https://github.com/rust-lang/crates.io-index.git "$CRATESFYI_PREFIX"/crates.io-index
RUN git --git-dir="$CRATESFYI_PREFIX"/crates.io-index/.git branch crates-index-diff_last-seen

### STEP 4: Build the project ###
# 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
# and doing a full build with it.
RUN mkdir -p ~/docs.rs ~/docs.rs/src/web/badge
WORKDIR $HOME/docs.rs
COPY --chown=cratesfyi Cargo.lock Cargo.toml ./
COPY --chown=cratesfyi src/web/badge src/web/badge/
RUN echo "fn main() {}" > src/main.rs && \
echo "fn main() {}" > build.rs

RUN cargo fetch
RUN cargo build --release

### STEP 5: Build the website ###
# 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
# source code didn't change thanks to mtime weirdness.
RUN rm -rf src build.rs
COPY --chown=cratesfyi src src/
COPY --chown=cratesfyi build.rs build.rs
COPY --chown=cratesfyi templates templates/
RUN touch build.rs && find src -name "*.rs" -exec touch {} \; && cargo build --release

ADD css $CRATESFYI_PREFIX/public_html

ENV DOCS_RS_DOCKER=true
COPY docker-entrypoint.sh ./
USER root
ENTRYPOINT ./docker-entrypoint.sh
Binary file added css/FiraSans-Medium.woff
Binary file not shown.
Binary file added css/FiraSans-Regular.woff
Binary file not shown.
Binary file added css/SourceCodePro-Regular.woff
Binary file not shown.
Binary file added css/SourceCodePro-Semibold.woff
Binary file not shown.
Binary file added css/SourceSerifPro-Bold.woff
Binary file not shown.
Binary file added css/SourceSerifPro-It.ttf.woff
Binary file not shown.
Binary file added css/SourceSerifPro-Regular.ttf.woff
Binary file not shown.
Binary file added css/SourceSerifPro-Regular.woff
Binary file not shown.
1 change: 1 addition & 0 deletions css/brush-20191010-1.40.0-nightly-898f36c83.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions css/main-20191010-1.40.0-nightly-898f36c83.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions css/settings-20191010-1.40.0-nightly-898f36c83.js

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

1 change: 1 addition & 0 deletions css/source-script-20191010-1.40.0-nightly-898f36c83.js

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

1 change: 1 addition & 0 deletions css/storage-20191010-1.40.0-nightly-898f36c83.js

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