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

Gitlab/ECR Hybrid action fails when pip installing awscli directly into the root environment #178

Open
mgrinshpon opened this issue May 14, 2024 · 0 comments

Comments

@mgrinshpon
Copy link

mgrinshpon commented May 14, 2024

before_script:
# # For Gitlab Container Registry
# - echo $CI_JOB_TOKEN | docker login --username $CI_REGISTRY_USER --password-stdin $REGISTRY_URL
# # For DockerHub
# - echo $DOCKERHUB_TOKEN | docker login --username $DOCKERHUB_USERNAME --password-stdin $REGISTRY_URL
# # For AWS Elastic Container Registry (ECR)
# - apk add --no-cache curl jq python3 py3-pip
# - pip install awscli
# - echo $AWS_ECR_PASSWORD | docker login --username AWS --password-stdin $IMAGE_REGISTRY
# # For Google Container Registry (GCR)
# - echo $GCR_JSON_KEY | docker login --username _json_key --password-stdin $REGISTRY_URL

These lines right here are problematic because when running pip install awscli, it installs right into root causing the following failure:

$ pip install awscli
error: externally-managed-environment
× This environment is externally managed
╰─> 
    The system-wide python installation should be maintained using the system
    package manager (apk) only.
    
    If the package in question is not packaged already (and hence installable via
    "apk add py3-somepackage"), please consider installing it inside a virtual
    environment, e.g.:
    
    python3 -m venv /path/to/venv
    . /path/to/venv/bin/activate
    pip install mypackage
    
    To exit the virtual environment, run:
    
    deactivate
    
    The virtual environment is not deleted, and can be re-entered by re-sourcing
    the activate file.
    
    To automatically manage virtual environments, consider using pipx (from the
    pipx package).

Hacking through it by allowing system packages to break yields an error when building awscrt:

$ pip install awscli --break-system-packages
....
        File "<string>", line 263, in run
        File "<string>", line 255, in _build_dependencies
        File "<string>", line 163, in _build_dependencies_impl
        File "<string>", line 121, in get_cmake_path
      Exception: CMake must be installed to build from source.
      [end of output]

An alternative could be to just use apk add aws-cli rather than installing through pypi. That lets you skip the python install entirely. Lines 62-63 then just become the following:

- apk add --no-cache curl jq aws-cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant