Skip to content

Commit fc3ce18

Browse files
authored
scripts: add fully_reset_environment.sh and update docker/README.md (#12318)
1 parent 4625b57 commit fc3ce18

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

docker/README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,13 @@ docker compose rm -v
113113

114114
## Fully Resetting Your Environment
115115

116-
Been away for a while? Are you getting strange errors you weren't getting before? Sometimes changes are made to the docker configs which could cause your local environment to break. To do a full reset of your docker environment so that you have the latest of everything:
116+
Been away for a while? Are you getting strange errors you weren't getting before? Sometimes changes are made to the docker configs which could cause your local environment to break.
117+
To do a full reset, run the following script from the root of the repo:
117118

118-
```sh
119-
# Stop the site
120-
docker compose down
121-
122-
# Build the latest oldev image, without cache, whilst also pulling the latest olbase image from docker hub.
123-
# This can take from a few minutes to more than 20 on older hardware.
124-
docker compose build --pull --no-cache
125-
126-
# Remove any old containers/images
127-
# If you use docker for other things, and have containers/images you don't want to lose, be careful with this. But you likely don't :)
128-
docker container prune --filter label="com.docker.compose.project=openlibrary" --force
129-
docker image prune --filter label="com.docker.compose.project=openlibrary" --force
119+
[`scripts/fully_reset_environment.sh`](https://github.com/internetarchive/openlibrary/blob/master/scripts/fully_reset_environment.sh)
130120

131-
# Remove volumes that might have outdated dependencies/code
132-
docker volume rm openlibrary_ol-build openlibrary_ol-nodemodules openlibrary_ol-postgres openlibrary_ol-vendor openlibrary_solr-data openlibrary_solr-updater-data
133-
134-
# Bring it back up again
135-
docker compose up # or docker compose up -d
121+
```sh
122+
bash scripts/fully_reset_environment.sh
136123
```
137124

138125
## Troubleshooting

scripts/fully_reset_environment.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# Fully resets the local OpenLibrary Docker environment.
3+
#
4+
# Been away for a while? Getting strange errors you weren't getting before?
5+
# Sometimes changes are made to the docker configs which could cause your
6+
# local environment to break. This script does a full reset so that you
7+
# have the latest of everything.
8+
#
9+
# Usage (run from the root of the openlibrary repo):
10+
# ./scripts/fully_reset_environment.sh
11+
#
12+
# WARNING: This is destructive. All local volumes and databases will be wiped.
13+
# See docker/README.md for more context.
14+
15+
set -euo pipefail
16+
17+
# Stop the site
18+
docker compose down
19+
20+
# Build the latest oldev image, without cache, whilst also pulling the latest olbase image from docker hub.
21+
# This can take from a few minutes to more than 20 on older hardware.
22+
docker compose build --pull --no-cache
23+
24+
# Remove any old containers/images
25+
# If you use docker for other things, and have containers/images you don't want to lose, be careful with this. But you likely don't :)
26+
docker container prune --filter label="com.docker.compose.project=openlibrary" --force
27+
docker image prune --filter label="com.docker.compose.project=openlibrary" --force
28+
29+
# Remove volumes that might have outdated dependencies/code
30+
docker volume rm \
31+
openlibrary_ol-build \
32+
openlibrary_ol-nodemodules \
33+
openlibrary_ol-postgres \
34+
openlibrary_ol-vendor \
35+
openlibrary_solr-data \
36+
openlibrary_solr-updater-data
37+
38+
# Bring it back up again
39+
docker compose up -d

0 commit comments

Comments
 (0)