Skip to content

Commit b0c43d1

Browse files
authored
Merge pull request #432 from jyn514/docker-in-docker
Add dockerfile
2 parents e95c89b + cf2ebdc commit b0c43d1

25 files changed

+644
-13
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.rustwide
2+
**/target

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM rust:slim
2+
3+
### STEP 1: Install dependencies ###
4+
# Install packaged dependencies
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
build-essential git curl cmake gcc g++ pkg-config libmagic-dev \
7+
libssl-dev zlib1g-dev sudo docker.io
8+
9+
### STEP 2: Create user ###
10+
ENV HOME=/home/cratesfyi
11+
RUN adduser --home $HOME --disabled-login --disabled-password --gecos "" cratesfyi
12+
13+
### STEP 3: Setup build environment as new user ###
14+
ENV CRATESFYI_PREFIX=/home/cratesfyi/prefix
15+
RUN mkdir $CRATESFYI_PREFIX && chown cratesfyi:cratesfyi "$CRATESFYI_PREFIX"
16+
17+
USER cratesfyi
18+
RUN mkdir -vp "$CRATESFYI_PREFIX"/documentations "$CRATESFYI_PREFIX"/public_html "$CRATESFYI_PREFIX"/sources
19+
RUN git clone https://github.com/rust-lang/crates.io-index.git "$CRATESFYI_PREFIX"/crates.io-index
20+
RUN git --git-dir="$CRATESFYI_PREFIX"/crates.io-index/.git branch crates-index-diff_last-seen
21+
22+
### STEP 4: Build the project ###
23+
# Build the dependencies in a separate step to avoid rebuilding all of them
24+
# every time the source code changes. This takes advantage of Docker's layer
25+
# caching, and it works by copying the Cargo.{toml,lock} with dummy source code
26+
# and doing a full build with it.
27+
RUN mkdir -p ~/docs.rs ~/docs.rs/src/web/badge
28+
WORKDIR $HOME/docs.rs
29+
COPY --chown=cratesfyi Cargo.lock Cargo.toml ./
30+
COPY --chown=cratesfyi src/web/badge src/web/badge/
31+
RUN echo "fn main() {}" > src/main.rs && \
32+
echo "fn main() {}" > build.rs
33+
34+
RUN cargo fetch
35+
RUN cargo build --release
36+
37+
### STEP 5: Build the website ###
38+
# Dependencies are now cached, copy the actual source code and do another full
39+
# build. The touch on all the .rs files is needed, otherwise cargo assumes the
40+
# source code didn't change thanks to mtime weirdness.
41+
RUN rm -rf src build.rs
42+
COPY --chown=cratesfyi src src/
43+
COPY --chown=cratesfyi build.rs build.rs
44+
COPY --chown=cratesfyi templates templates/
45+
RUN touch build.rs && find src -name "*.rs" -exec touch {} \; && cargo build --release
46+
47+
ADD css $CRATESFYI_PREFIX/public_html
48+
49+
ENV DOCS_RS_DOCKER=true
50+
COPY docker-entrypoint.sh ./
51+
USER root
52+
ENTRYPOINT ./docker-entrypoint.sh

css/FiraSans-Medium.woff

182 KB
Binary file not shown.

css/FiraSans-Regular.woff

179 KB
Binary file not shown.

css/SourceCodePro-Regular.woff

54.2 KB
Binary file not shown.

css/SourceCodePro-Semibold.woff

54.1 KB
Binary file not shown.

css/SourceSerifPro-Bold.woff

47.6 KB
Binary file not shown.

css/SourceSerifPro-It.ttf.woff

35.4 KB
Binary file not shown.

css/SourceSerifPro-Regular.ttf.woff

86.5 KB
Binary file not shown.

css/SourceSerifPro-Regular.woff

48.8 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Loading

css/favicon.ico

4.19 KB
Binary file not shown.

css/main-20191010-1.40.0-nightly-898f36c83.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/settings-20191010-1.40.0-nightly-898f36c83.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/source-script-20191010-1.40.0-nightly-898f36c83.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/storage-20191010-1.40.0-nightly-898f36c83.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)