-
Notifications
You must be signed in to change notification settings - Fork 6
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 virtual env path environment variable in Dockerfile #46
Open
rominf
wants to merge
1
commit into
kausaltech:main
Choose a base branch
from
rominf:rominf-dockerfile-pip
base: main
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.
Conversation
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
Currently, docker build fails because `pip` is not found: ``` $ podman-compose -f docker-compose.dev.yml -f docker-compose.yml --podman-build-args="--security-opt label=disable" up --build --build-arg INSTALL_DEV_DEPS=0 --build-arg BUILD_ID=0 ... [3/4] STEP 13/13: RUN --mount=type=cache,target=${XDG_CACHE_HOME}/pip if [ ! -z "${INSTALL_DEV_DEPS}" ] ; then ${VENV_PATH}/bin/pip install -r ${app_path}/requirements-dev.txt ; fi /bin/sh: 1: /bin/pip: not found Error: building at STEP "RUN --mount=type=cache,target=${XDG_CACHE_HOME}/pip if [ ! -z "${INSTALL_DEV_DEPS}" ] ; then ${VENV_PATH}/bin/pip install -r ${app_path}/requirements-dev.txt ; fi": while running runtime: exit status 127 ``` The reason for this is that `VENV_PATH` is defined below it is used. The change leverages that `VIRTUAL_ENV` is already defined, and the fact that: > A stage inherits any environment variables that were set using ENV by > its parent stage or any ancestor. (see: https://docs.docker.com/reference/dockerfile/#env) The line with `PATH` is deleted because it is unnecessary because of the same fact. Note that I ran `podman-compose` because Fedora comes with `podman`, not `docker`, yet here the behavior of `podman` and `docker` are identical.
e58e36b
to
1e3021e
Compare
rominf
added a commit
to rominf/kausal-paths
that referenced
this pull request
Jun 27, 2024
After applying changes from kausaltech#46, Docker does not build still. ``` $ podman-compose -f docker-compose.dev.yml -f docker-compose.yml --podman-build-args="--security-opt label=disable" up --build --build-arg INSTALL_DEV_DEPS=0 --build-arg BUILD_ID=0 [4/4] STEP 15/32: RUN groupadd -g ${app_user_gid} user && useradd --no-log-init -m -d /home/user -g ${app_user_gid} -u ${app_user_uid} -r user groupadd: invalid group ID 'user' Error: building at STEP "RUN groupadd -g ${app_user_gid} user && useradd --no-log-init -m -d /home/user -g ${app_user_gid} -u ${app_user_uid} -r user": while running runtime: exit status 3 ``` The reason is incorrect scope for multiple `ARG`s: > An ARG instruction goes out of scope at the end of the build stage > where it was defined. To use an argument in multiple stages, each stage > must include the ARG instruction. (see: https://docs.docker.com/reference/dockerfile/#scope) The change fixes the scope for all `ARG`s. Note that I ran `podman-compose` because Fedora comes with `podman`, not `docker`, yet here the behavior of `podman` and `docker` are identical.
rominf
added a commit
to rominf/kausal-paths
that referenced
this pull request
Jun 27, 2024
After applying changes from kausaltech#46, Docker does not build still. ``` $ podman-compose -f docker-compose.dev.yml -f docker-compose.yml --podman-build-args="--security-opt label=disable" up --build --build-arg INSTALL_DEV_DEPS=0 --build-arg BUILD_ID=0 [4/4] STEP 15/32: RUN groupadd -g ${app_user_gid} user && useradd --no-log-init -m -d /home/user -g ${app_user_gid} -u ${app_user_uid} -r user groupadd: invalid group ID 'user' Error: building at STEP "RUN groupadd -g ${app_user_gid} user && useradd --no-log-init -m -d /home/user -g ${app_user_gid} -u ${app_user_uid} -r user": while running runtime: exit status 3 ``` The reason is incorrect scope for multiple `ARG`s: > An ARG instruction goes out of scope at the end of the build stage > where it was defined. To use an argument in multiple stages, each stage > must include the ARG instruction. (see: https://docs.docker.com/reference/dockerfile/#scope) The change fixes the scope for all `ARG`s, so that build succeeds. Note that I ran `podman-compose` because Fedora comes with `podman`, not `docker`, yet here the behavior of `podman` and `docker` are identical.
rominf
added a commit
to rominf/kausal-paths
that referenced
this pull request
Jun 27, 2024
On docker build after changes from: kausaltech#46 and kausaltech#47 I am getting: ``` $ podman-compose -f docker-compose.dev.yml -f docker-compose.yml --podman-build-args="--security-opt label=disable" up --build --build-arg INSTALL_DEV_DEPS=0 --build-arg BUILD_ID=0 ... Execution of msgfmt failed: msgfmt: error while opening "/venv/lib/python3.12/site-packages/django_filters/locale/fi/LC_MESSAGES/django.mo" for writing: Permission denied ... CommandError: compilemessages generated one or more errors. ``` The change fixes permission errors by adding required dirs to `chown -R` call. After this build finally succeeds. Note that I ran `podman-compose` because Fedora comes with `podman`, not `docker`, yet here the behavior of `podman` and `docker` are identical.
rominf
added a commit
to rominf/kausal-paths
that referenced
this pull request
Jun 27, 2024
On docker build after changes from: kausaltech#46 and kausaltech#47 there is a build error still: ``` $ podman-compose -f docker-compose.dev.yml -f docker-compose.yml --podman-build-args="--security-opt label=disable" up --build --build-arg INSTALL_DEV_DEPS=0 --build-arg BUILD_ID=0 ... Execution of msgfmt failed: msgfmt: error while opening "/venv/lib/python3.12/site-packages/django_filters/locale/fi/LC_MESSAGES/django.mo" for writing: Permission denied ... CommandError: compilemessages generated one or more errors. ``` The change fixes permission errors by adding required dirs to `chown -R` call. After this build finally succeeds. Note that I ran `podman-compose` because Fedora comes with `podman`, not `docker`, yet here the behavior of `podman` and `docker` are identical.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, docker build fails because
pip
is not found:The reason for this is that
VENV_PATH
is defined below it is used. The change leverages thatVIRTUAL_ENV
is already defined, and the fact that:(see: https://docs.docker.com/reference/dockerfile/#env)
The line with
PATH
is deleted because it is unnecessary because of thesame fact.
Note that I ran
podman-compose
because Fedora comes withpodman
, notdocker
, yet here the behavior ofpodman
anddocker
are identical.