Skip to content
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

fix (build): Dev Env container can now be built locally on Fedora #516

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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