Skip to content

Commit

Permalink
chore: update environment with rustup cache, podman compat (#14237)
Browse files Browse the repository at this point in the history
* chore: ignore emacs backup files

* chore: add hints about SELinux container_file_t

* chore: cache rustup toolchain download

* chore: let git treat source code volume as safe

Now we can use `git status` for quick review, while committing still
prints empty user warning.

* chore: mount docker.sock only when using docker
  • Loading branch information
hdhoang authored Sep 8, 2022
1 parent c745d25 commit 3c8f8de
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cargo-timing*.html
*.pyc
*.iml
*.tmp
*~
**/*.rs.bk
.DS_Store
.idea/
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ FORMATTING_END = \033[0m
# "One weird trick!" https://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
EMPTY:=
SPACE:= ${EMPTY} ${EMPTY}
COMMA:= ,

help:
@printf -- "${FORMATTING_BEGIN_BLUE} __ __ __${FORMATTING_END}\n"
Expand Down Expand Up @@ -119,9 +120,10 @@ define ENVIRONMENT_EXEC
--env INSIDE_ENVIRONMENT=true \
--network host \
--mount type=bind,source=${CURRENT_DIR},target=/git/vectordotdev/vector \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
$(if $(findstring docker,$(CONTAINER_TOOL)),--mount type=bind$(COMMA)source=/var/run/docker.sock$(COMMA)target=/var/run/docker.sock,) \
--mount type=volume,source=vector-target,target=/git/vectordotdev/vector/target \
--mount type=volume,source=vector-cargo-cache,target=/root/.cargo \
--mount type=volume,source=vector-rustup-cache,target=/root/.rustup \
$(ENVIRONMENT_UPSTREAM)
endef

Expand Down Expand Up @@ -157,7 +159,7 @@ environment-prepare: ## Prepare the Vector dev shell using $CONTAINER_TOOL.

.PHONY: environment-clean
environment-clean: ## Clean the Vector dev shell using $CONTAINER_TOOL.
@$(CONTAINER_TOOL) volume rm -f vector-target vector-cargo-cache
@$(CONTAINER_TOOL) volume rm -f vector-target vector-cargo-cache vector-rustup-cache
@$(CONTAINER_TOOL) rmi $(ENVIRONMENT_UPSTREAM) || true

.PHONY: environment-push
Expand Down
8 changes: 8 additions & 0 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ This is ideal for users who want it to "Just work" and just want to start contri
export CONTAINER_TOOL="podman"
```

If your Linux environment runs SELinux in Enforcing mode, you will need to relabel the vector source code checkout with `container_home_t` context. Otherwise the container environment cannot read/write the code:

```bash
cd your/checkout/of/vector/
sudo semanage fcontext -a "${PWD}(/.*)?" -t container_file_t
sudo restorecon . -R
```

By default, `make environment` style tasks will do a `docker pull` from Github's container repository, you can **optionally** build your own environment while you make your morning coffee ☕:

```bash
Expand Down
1 change: 1 addition & 0 deletions scripts/environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RUN ./scripts/environment/prepare.sh && ./scripts/environment/setup-helm.sh
VOLUME /vector
VOLUME /vector/target
VOLUME /root/.cargo
VOLUME /root/.rustup

# Prepare for use
COPY ./scripts/environment/entrypoint.sh /
Expand Down
2 changes: 2 additions & 0 deletions scripts/environment/prepare.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /usr/bin/env bash
set -e -o verbose

git config --global --add safe.directory /git/vectordotdev/vector

rustup show # causes installation of version from rust-toolchain.toml
rustup default "$(rustup show active-toolchain | awk '{print $1;}')"
if [[ "$(cargo-deb --version)" != "1.29.2" ]] ; then
Expand Down

0 comments on commit 3c8f8de

Please sign in to comment.