-
Notifications
You must be signed in to change notification settings - Fork 198
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 registry-watcher image and separate docker-compose services #2269
Open
Nemo157
wants to merge
5
commits into
rust-lang:master
Choose a base branch
from
Nemo157:docker-compose-services
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+231
−157
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fb98c34
Update readme for docker-compose v2
Nemo157 f38999e
Update CI to use docker-compose v2
Nemo157 1e7016f
Don't bind internal docker-compose services to external IPs
Nemo157 80a5011
Run separate web server, registry watcher and build servers in docker…
Nemo157 303eb68
Ignore more files that are irrelevant to building a docker image
Nemo157 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
/target/ | ||
/.rustwide | ||
/.rustwide-docker | ||
/Justfile | ||
/LICENSE | ||
/README.md | ||
/docker-compose.yml | ||
/docs/ | ||
/ignored | ||
**/target | ||
/mcps | ||
/triagebot.toml | ||
/clippy.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/ignored | ||
/.env | ||
/.docker.env | ||
/src/web/badge/Cargo.lock | ||
target | ||
*.css | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,8 +64,7 @@ mkdir -p ignored/cratesfyi-prefix/crates.io-index | |
# Builds the docs.rs binary | ||
cargo build | ||
# Start the external services. | ||
# It may be `docker compose` in newer versions | ||
docker-compose up -d db s3 | ||
docker compose up --wait db s3 | ||
# anything that doesn't run via docker-compose needs the settings defined in | ||
# .env. Either via `. ./.env` as below, or via any dotenv shell integration. | ||
. ./.env | ||
|
@@ -111,19 +110,37 @@ can take a look at its documentation [here](https://github.com/GuillaumeGomez/br | |
|
||
### Pure docker-compose | ||
|
||
If you have trouble with the above commands, consider using `docker-compose up --build`, | ||
If you have trouble with the above commands, consider using `docker compose up --build`, | ||
which uses docker-compose for the web server as well. | ||
This will not cache dependencies - in particular, you'll have to rebuild all 400 whenever the lockfile changes - | ||
but makes sure that you're in a known environment so you should have fewer problems getting started. | ||
|
||
You can also use the `web` container to run builds on systems which don't support running builds directly (mostly on Mac OS or Windows): | ||
You'll need to `touch .docker.env` first, this file can have any environment | ||
variable overrides you want to use in docker containers. | ||
|
||
You can also use the `builder-a` container to run builds on systems which don't support running builds directly (mostly on Mac OS or Windows): | ||
|
||
```sh | ||
# update the toolchain | ||
docker compose run --rm builder-a build update-toolchain | ||
# run a build for a single crate | ||
docker-compose run web build crate regex 1.3.1 | ||
# or build essential files | ||
docker-compose run web build add-essential-files | ||
# rebuild the web container when you changed code. | ||
docker-compose build web | ||
docker compose run --rm builder-a build crate regex 1.3.1 | ||
# rebuild containers when you changed code. | ||
docker compose up --wait --build | ||
``` | ||
|
||
You can also run other non-build commands like the setup steps above, or queueing crates for the background builders from within the `cli` container: | ||
|
||
```sh | ||
docker compose run --rm cli database migrate | ||
docker compose run --rm cli queue add regex 1.3.1 | ||
``` | ||
|
||
If the command needs the crates.io-index clone then it must be run from within | ||
a `registry-watcher` container: | ||
|
||
```sh | ||
docker compose run --rm registry-watcher queue set-last-seen-reference --head | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, the command has to be run initially, to be able to use the |
||
``` | ||
|
||
Note that running tests is not supported when using pure docker-compose. | ||
|
@@ -137,22 +154,22 @@ Three services are defined: | |
|
||
| name | access | credentials | description | | ||
|------|-------------------------------------------------|----------------------------|----------------------------------------| | ||
| web | http://localhost:3000 | N/A | A container running the docs.rs binary | | ||
| db | postgresql://cratesfyi:password@localhost:15432 | - | Postgres database used by web | | ||
| s3 | http://localhost:9000 | `cratesfyi` - `secret_key` | MinIO (simulates AWS S3) used by web | | ||
| web | http://0.0.0.0:3000 | N/A | A container running the docs.rs binary | | ||
| db | postgresql://cratesfyi:password@127.0.0.1:15432 | - | Postgres database used by web | | ||
| s3 | http://127.0.0.1:9000 | `cratesfyi` - `secret_key` | MinIO (simulates AWS S3) used by web | | ||
|
||
[docker-compose.yml]: ./docker-compose.yml | ||
|
||
#### Rebuilding Containers | ||
|
||
To rebuild the site, run `docker-compose build`. | ||
To rebuild the site, run `docker compose --profile all build`. | ||
Note that docker-compose caches the build even if you change the source code, | ||
so this will be necessary anytime you make changes. | ||
|
||
If you want to completely clean up the database, don't forget to remove the volumes too: | ||
|
||
```sh | ||
$ docker-compose down --volumes | ||
$ docker compose down --volumes | ||
``` | ||
|
||
#### FAQ | ||
|
@@ -166,7 +183,7 @@ This is probably because you have `git.autocrlf` set to true, | |
|
||
##### I see the error `/opt/rustwide/cargo-home/bin/cargo: cannot execute binary file: Exec format error` when running builds. | ||
|
||
You are most likely not on a Linux platform. Running builds directly is only supported on `x86_64-unknown-linux-gnu`. On other platforms you can use the `docker-compose run web build [...]` workaround described above. | ||
You are most likely not on a Linux platform. Running builds directly is only supported on `x86_64-unknown-linux-gnu`. On other platforms you can use the `docker compose run --rm builder-a build [...]` workaround described above. | ||
|
||
See [rustwide#41](https://github.com/rust-lang/rustwide/issues/41) for more details about supporting more platforms directly. | ||
|
||
|
@@ -194,11 +211,11 @@ cargo run -- start-web-server | |
```sh | ||
# Builds <CRATE_NAME> <CRATE_VERSION> and adds it into database | ||
# This is the main command to build and add a documentation into docs.rs. | ||
# For example, `docker-compose run web build crate regex 1.1.6` | ||
# For example, `docker compose run --rm builder-a build crate regex 1.1.6` | ||
cargo run -- build crate <CRATE_NAME> <CRATE_VERSION> | ||
|
||
# alternatively, via the web container | ||
docker-compose run web build crate <CRATE_NAME> <CRATE_VERSION> | ||
# alternatively, within docker-compose containers | ||
docker compose run --rm builder-a build crate <CRATE_NAME> <CRATE_VERSION> | ||
|
||
# Builds every crate on crates.io and adds them into database | ||
# (beware: this may take months to finish) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not clear that you have to run this command to make the service work.