Skip to content

Commit

Permalink
fix (build): Dev Env container can now be built locally on Fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Feb 20, 2024
1 parent 3be6a6c commit 206d2f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
18 changes: 15 additions & 3 deletions Dockerfile-DevEnv
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,22 @@ USER developer
# https://go.dev/doc/install (adapted for Fedora, which does not use ~/.profile, and ignores PATH in ~/.bash_profile)
RUN echo "export PATH=$PATH:/home/developer/go/bin" >> /home/developer/.bashrc

ADD tools/go/install.bash /tmp/go-install.bash
RUN /tmp/go-install.bash
# It's a bit dumb that we have a manually maintained list of "essential initial dev env set-up" files here...
# An alternative could be to use 'RUN --mount=type=bind,source=.,target=/workspace/', but this has been
# observed to work inconsistently between older/newer Docker versions, as well as with Podman on Fedora
# (see https://github.com/enola-dev/enola/issues/515), so let's just do it like this, unless someone
# reading this has a better idea! [Note that it only makes sense to "pre-warm" tools that end up in
# $HOME; but any tools in the "repo" (/workspace) cannot be pre-loaded, as the $PWD mount hides it.

ADD tools /workspace/tools
ADD .tool-versions /workspace/
ADD .bazel* /workspace/
ADD WORKSPACE* /workspace/
ADD MODULE* /workspace/
ADD BUILD /workspace/
ADD maven_install.json /workspace/

WORKDIR /workspace/
RUN --mount=type=bind,source=.,target=/workspace/ /workspace/tools/devenv/install.bash
RUN /workspace/tools/devenv/install.bash

# See https://docs.docker.com/build/guide/mounts/ for documentation about --mount=type.
9 changes: 8 additions & 1 deletion devenv.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ set -euo pipefail

docker build -t enola.dev-devenv --rm -f Dockerfile-DevEnv .

docker run -v .:/workspace/:Z -it --rm enola.dev-devenv
# NB: Use PWD instead of . here because different of different . intepretations;
# between older/newer Docker (and Podman...) versions - at least some older Docker
# versions have been observed to fail, because they assume . to be a volume name! :/)
set +u
if [ -z "$CI" ]; then
docker run -v "$PWD":/workspace/:Z -it --rm enola.dev-devenv
fi
set -u
11 changes: 6 additions & 5 deletions tools/devenv/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ set -euo pipefail

# This script prepares the Development Environment container.

tools/pre-commit/install.bash
tools/go/install.bash

# TODO After https://github.com/enola-dev/enola/pull/452, uncomment:
# $(go env GOPATH)/bin/bazelisk run //tools/hello

# TODO tools/git/install-hooks.bash
# This is a simple initial test, without fully building Enola, just yet:
# We're doing this here (a) to test, and (b) and more importantly to
# "pre-load" ("warm up") the Bazel distribution in the container image
# at ~/.cache/bazel.
"$(go env GOPATH)"/bin/bazelisk run //tools/hello

0 comments on commit 206d2f9

Please sign in to comment.