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

Поддержка 1cedtcli и переход на базовый образ с JDK 17 для EDT 2024.1.0+ #53

Merged
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
11 changes: 11 additions & 0 deletions build-edt-k8s-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then
docker system prune -af
fi

#Если версия EDT >= 2024.1.0, использовать JDK 17
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
nixel2007 marked this conversation as resolved.
Show resolved Hide resolved
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi

last_arg='.'
if [ "${NO_CACHE}" = 'true' ] ; then
last_arg='--no-cache .'
Expand All @@ -37,6 +46,8 @@ docker build \
--build-arg ONEC_USERNAME=$ONEC_USERNAME \
--build-arg ONEC_PASSWORD=$ONEC_PASSWORD \
--build-arg EDT_VERSION="$EDT_VERSION" \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg BASE_TAG=$BASE_TAG \
--build-arg DOWNLOADER_REGISTRY_URL=$DOCKER_REGISTRY_URL \
--build-arg DOWNLOADER_IMAGE=oscript-downloader \
--build-arg DOWNLOADER_TAG=latest \
Expand Down
14 changes: 13 additions & 1 deletion build-edt-swarm-agent.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af

if %ERRORLEVEL% neq 0 goto end

for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%aa
if %EDT_MAJOR_VERSION% GEQ "2024" (
set BASE_IMAGE="azul/zulu-openjdk"
set BASE_TAG="17"
) else (
set BASE_IMAGE="eclipse-temurin"
set BASE_TAG="11"
)

if %ERRORLEVEL% neq 0 goto end

nixel2007 marked this conversation as resolved.
Show resolved Hide resolved
if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".")

set edt_version=%EDT_VERSION%
set edt_escaped=%edt_version: =_%


docker build ^
--pull ^
--build-arg DOCKER_REGISTRY_URL=library ^
Expand All @@ -28,6 +38,8 @@ docker build ^
--build-arg ONEC_USERNAME=%ONEC_USERNAME% ^
--build-arg ONEC_PASSWORD=%ONEC_PASSWORD% ^
--build-arg EDT_VERSION=%EDT_VERSION% ^
--build-arg BASE_IMAGE=%BASE_IMAGE% ^
--build-arg BASE_TAG=%BASE_TAG% ^
--build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^
--build-arg DOWNLOADER_IMAGE=oscript-downloader ^
--build-arg DOWNLOADER_TAG=latest ^
Expand Down
11 changes: 11 additions & 0 deletions build-edt-swarm-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then
docker system prune -af
fi

#Если версия EDT >= 2024.1.0, использовать JDK 17
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi

last_arg='.'
if [ "${NO_CACHE}" = 'true' ] ; then
last_arg='--no-cache .'
Expand All @@ -37,6 +46,8 @@ docker build \
--build-arg ONEC_USERNAME=$ONEC_USERNAME \
--build-arg ONEC_PASSWORD=$ONEC_PASSWORD \
--build-arg EDT_VERSION="$EDT_VERSION" \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg BASE_TAG=$BASE_TAG \
--build-arg DOWNLOADER_REGISTRY_URL=$DOCKER_REGISTRY_URL \
--build-arg DOWNLOADER_IMAGE=oscript-downloader \
--build-arg DOWNLOADER_TAG=latest \
Expand Down
8 changes: 5 additions & 3 deletions edt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ENV LC_ALL ru_RU.UTF-8

RUN /download.sh "$ONEC_USERNAME" "$ONEC_PASSWORD" "$EDT_VERSION" "edt"

FROM ${DOCKER_REGISTRY_URL}/${BASE_IMAGE}:${BASE_TAG}
FROM ${BASE_IMAGE}:${BASE_TAG}

LABEL maintainer="Nikita Gryzlov <[email protected]>, FirstBit"

Expand Down Expand Up @@ -70,6 +70,8 @@ WORKDIR /tmp/${downloads}
RUN chmod +x ./1ce-installer-cli \
&& ./1ce-installer-cli install all --ignore-hardware-checks --ignore-signature-warnings\
&& rm -rf /tmp/* \
&& mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring
&& mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring \
#1cedtcli отсутствует в EDT версии <2023.1.0
&& if [ -n "$(find /opt/1C/1CE -name 1cedtcli)" ]; then mv $(dirname $(find /opt/1C/1CE -name 1cedtcli)) /opt/1C/1CE/components/1cedtcli; fi
Comment on lines +73 to +75
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Optimize component installation and add error handling

The current implementation has several areas for improvement:

  1. The find command is executed multiple times
  2. No error handling for the ring component move
  3. Silent failures possible in the conditional move

Consider this more robust implementation:

-  && mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring \
-  #1cedtcli отсутствует в EDT версии <2023.1.0
-  && if [ -n "$(find /opt/1C/1CE -name 1cedtcli)" ]; then mv $(dirname $(find /opt/1C/1CE -name 1cedtcli)) /opt/1C/1CE/components/1cedtcli; fi
+  && RING_PATH=$(find /opt/1C/1CE -name ring) \
+  && if [ -z "$RING_PATH" ]; then echo "Error: ring component not found" && exit 1; fi \
+  && mv "$(dirname "$RING_PATH")" /opt/1C/1CE/components/1c-enterprise-ring \
+  # 1cedtcli is only available in EDT version 2023.1.0 and above \
+  && CEDTCLI_PATH=$(find /opt/1C/1CE -name 1cedtcli) \
+  && if [ -n "$CEDTCLI_PATH" ]; then \
+       mv "$(dirname "$CEDTCLI_PATH")" /opt/1C/1CE/components/1cedtcli \
+     || { echo "Error moving 1cedtcli component"; exit 1; }; \
+     fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&& mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring \
#1cedtcli отсутствует в EDT версии <2023.1.0
&& if [ -n "$(find /opt/1C/1CE -name 1cedtcli)" ]; then mv $(dirname $(find /opt/1C/1CE -name 1cedtcli)) /opt/1C/1CE/components/1cedtcli; fi
&& RING_PATH=$(find /opt/1C/1CE -name ring) \
&& if [ -z "$RING_PATH" ]; then echo "Error: ring component not found" && exit 1; fi \
&& mv "$(dirname "$RING_PATH")" /opt/1C/1CE/components/1c-enterprise-ring \
# 1cedtcli is only available in EDT version 2023.1.0 and above \
&& CEDTCLI_PATH=$(find /opt/1C/1CE -name 1cedtcli) \
&& if [ -n "$CEDTCLI_PATH" ]; then \
mv "$(dirname "$CEDTCLI_PATH")" /opt/1C/1CE/components/1cedtcli \
|| { echo "Error moving 1cedtcli component"; exit 1; }; \
fi


ENV PATH="/opt/1C/1CE/components/1c-enterprise-ring:$PATH"
ENV PATH="/opt/1C/1CE/components/1c-enterprise-ring:/opt/1C/1CE/components/1cedtcli:$PATH"