forked from rust-lang/docs.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·41 lines (34 loc) · 1.14 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -euv
export CRATESFYI_PREFIX=/opt/docsrs/prefix
export DOCS_RS_DOCKER=true
export RUST_LOG=cratesfyi,rustwide=info
export PATH="$PATH:/build/target/release"
# Try migrating the database multiple times if it fails
# This avoids the docker container crashing the first time it's started with
# docker-compose, as PostgreSQL needs some time to initialize.
set +e
failed=0
while true; do
if ! cratesfyi database migrate; then
((failed=failed + 1))
if [ "${failed}" -eq 5 ]; then
exit 1
fi
echo "failed to migrate the database"
echo "waiting 1 second..."
sleep 1
else
break
fi
done
set -e
cratesfyi database update-search-index
cratesfyi database update-release-activity
if ! [ -d "${CRATESFYI_PREFIX}/crates.io-index/.git" ]; then
git clone https://github.com/rust-lang/crates.io-index "${CRATESFYI_PREFIX}/crates.io-index"
# Prevent new crates built before the container creation to be built
git --git-dir="$CRATESFYI_PREFIX/crates.io-index/.git" branch crates-index-diff_last-seen
fi
cratesfyi build update-toolchain --only-first-time
cratesfyi "$@"