Установить awscli в докере Java 17Python

Программы на Python
Anonymous
Установить awscli в докере Java 17

Сообщение Anonymous »

Я обновляю JAVA 8 до JAVA 17(

Код: Выделить всё

FROM amazoncorretto:17-alpine-jdk
) с одним из моих сервисов загрузки Spring. У меня есть awscli, который устанавливается, как показано ниже, в моем файле Dockerfile

Код: Выделить всё

RUN apk add --no-cache \
python3 \
py3-pip \
&& pip3 install --upgrade pip \
&& pip3 install --no-cache-dir \
awscli \
&& rm -rf /var/cache/apk/*
Но после обновления до Java17 у меня возникает проблема ниже, и я не могу продолжить предыдущий шаг

Код: Выделить всё

    => ERROR [plp-svc 2/7] RUN apk add --no-cache         python3         py3-pip     && pip3 install --upgrade pip     && pip3 install --no-cache-dir         awscli     && rm -rf /var/cache/apk/*              5.0s
------
> [plp-svc 2/7] RUN apk add --no-cache         python3         py3-pip     && pip3 install --upgrade pip     && pip3 install --no-cache-dir         awscli     && rm -rf /var/cache/apk/*:
0.165 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
0.546 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
0.894 fetch https://apk.corretto.aws/aarch64/APKINDEX.tar.gz
1.010 (1/25) Installing libexpat (2.6.2-r0)
1.033 (2/25) Installing libbz2 (1.0.8-r6)
1.054 (3/25) Installing libffi (3.4.4-r3)
1.383 (4/25) Installing gdbm (1.23-r1)
1.432 (5/25) Installing xz-libs (5.4.5-r0)
1.499 (6/25) Installing libgcc (13.2.1_git20231014-r0)
1.535 (7/25) Installing libstdc++ (13.2.1_git20231014-r0)
1.637 (8/25) Installing mpdecimal (2.5.1-r2)
1.668 (9/25) Installing ncurses-terminfo-base (6.4_p20231125-r0)
1.717 (10/25) Installing libncursesw (6.4_p20231125-r0)
1.763 (11/25) Installing libpanelw (6.4_p20231125-r0)
1.797 (12/25) Installing readline (8.2.1-r2)
1.879 (13/25) Installing sqlite-libs (3.44.2-r0)
2.007 (14/25) Installing python3 (3.11.9-r0)
3.018 (15/25) Installing python3-pycache-pyc0 (3.11.9-r0)
3.464 (16/25) Installing pyc (3.11.9-r0)
3.482 (17/25) Installing py3-setuptools-pyc (68.2.2-r0)
3.623 (18/25) Installing py3-pip-pyc (23.3.1-r0)
3.884 (19/25) Installing py3-parsing (3.1.1-r0)
3.913 (20/25) Installing py3-parsing-pyc (3.1.1-r0)
3.948 (21/25) Installing py3-packaging-pyc (23.2-r0)
3.974 (22/25) Installing python3-pyc (3.11.9-r0)
3.993 (23/25) Installing py3-packaging (23.2-r0)
4.020 (24/25) Installing py3-setuptools (68.2.2-r0)
4.103 (25/25) Installing py3-pip (23.3.1-r0)
4.320 Executing busybox-1.36.1-r15.trigger
4.324 OK: 398 MiB in 42 packages
4.778 error: externally-managed-environment
4.778
4.778 × This environment is externally managed
4.778 ╰─>
4.778     The system-wide python installation should be maintained using the system
4.778     package manager (apk) only.
4.778
4.778     If the package in question is not packaged already (and hence installable via
4.778     "apk add py3-somepackage"), please consider installing it inside a virtual
4.778     environment, e.g.:
4.778
4.778     python3 -m venv /path/to/venv
4.778     . /path/to/venv/bin/activate
4.778     pip install mypackage
4.778
4.778     To exit the virtual environment, run:
4.778
4.778     deactivate
4.778
4.778     The virtual environment is not deleted, and can be re-entered by re-sourcing
4.778     the activate file.
4.778
4.778     To automatically manage virtual environments, consider using pipx (from the
4.778     pipx package).
4.778
4.778 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
4.778 hint: See PEP 668 for the detailed specification.
------
failed to solve: process "/bin/sh -c apk add --no-cache         python3         py3-pip     && pip3 install --upgrade pip     && pip3 install --no-cache-dir         awscli     && rm -rf /var/cache/apk/*" did not complete successfully: exit code: 1
Можно ли как-нибудь запустить старую команду без использования виртуальной среды.
Я изменил свою команду, чтобы использовать виртуальную среду для установки awscli< /code> с командой ниже и все заработало.

Код: Выделить всё

#Install python3 and pip
RUN apk add --no-cache python3 py3-pip

# Create and activate a virtual environment, then install awscli
RUN python3 -m venv /venv \
&& .  /venv/bin/activate \
&& pip install --no-cache --upgrade pip \
&& pip install --no-cache awscli \
&& deactivate
Но моему приложению не удается получить учетные данные aws из-за ошибки ниже, поскольку оно не было установлено в виртуальной среде

Код: Выделить всё

Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path., com.amazonaws.auth.profile.ProfileCredentialsProvider@4afd1baf: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@7a2c4bf0: Failed to connect to service endpoint: ]
Любая помощь приветствуется.
Спасибо

Подробнее здесь: https://stackoverflow.com/questions/786 ... -17-docker

Вернуться в «Python»