diff --git a/.onec.env.example b/.onec.env.example index 7fa2541..8aa71db 100644 --- a/.onec.env.example +++ b/.onec.env.example @@ -2,6 +2,7 @@ export ONEC_USERNAME=onec export ONEC_PASSWORD=onec export ONEC_VERSION=8.3.18.1520 export EDT_VERSION=2021.2.7 +export COVERAGE41C_VERSION='' export DOCKER_REGISTRY_URL=docker-registry:5000 export DOCKER_LOGIN=login diff --git a/README.md b/README.md index 765e9f8..ced9d3e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ - [oscript](#oscript) - [vanessa-runner](#vanessa-runner) - [EDT](#edt) - + # Использование В терминале введите: @@ -46,7 +46,10 @@ copy .onec.env.bat.example env.bat * ONEC_USERNAME - учётная запись на http://releases.1c.ru * ONEC_PASSWORD - пароль для учётной записи на http://releases.1c.ru * ONEC_VERSION - версия платформы 1С:Преприятия 8.3, которая будет в образе +* EDT_VERSION - версия EDT. Обязательно заполнять только при сборке образов с EDT или при использовании замеров покрытия (см. `COVERAGE41C_VERSION`) * DOCKER_REGISTRY_URL - Адрес Docker-registry в котором будут храниться образы +* COVERAGE41C_VERSION - версия Coverage41C +Используется при сборке агента скриптами `build-base-*-jenkins-coverage-agent.*`. Затем экспортируйте все необходимые переменные: @@ -65,11 +68,13 @@ env.bat 1. Если вам нужны образы для использования в docker-swarm: - * build-base-swarm-jenkins-agent.sh + * build-base-swarm-jenkins-agent.sh (или build-base-swarm-jenkins-coverage-agent.sh с замерами покрытия) * build-edt-swarm-agent.sh * build-oscript-swarm-agent.sh -2. Если же вы планируете использовать k8s - * build-base-k8s-jenkins-agent.sh + +2. Если же вы планируете использовать k8s: + + * build-base-k8s-jenkins-agent.sh (или build-base-k8s-jenkins-coverage-agent.sh с замерами покрытия) * build-edt-k8s-agent.sh * build-oscript-k8s-agent.sh @@ -81,7 +86,7 @@ env.bat - взять ваш файл nethasp.ini - создать из него docker config командой `docker config create nethasp.ini ./nethasp.ini` -- в Jenkins, в настройках Docker Agent templates у соответствующих агентов в параметре Configs указать `nethasp.ini:/opt/1cv8/current/conf/nethasp.ini` +- в Jenkins, в настройках Docker Agent templates у соответствующих агентов в параметре Configs указать `nethasp.ini:/opt/1cv8/current/conf/nethasp.ini` ## Сервер [(Наверх)](#Оглавление) @@ -211,6 +216,7 @@ docker build --build-arg DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL} \ -t ${DOCKER_REGISTRY_URL}/runner:1.7.0 \ -f vanessa-runner/Dockerfile . ``` + ## EDT [(Наверх)](#Оглавление) ```bash diff --git a/build-base-k8s-jenkins-agent.sh b/build-base-k8s-jenkins-agent.sh index 9a8c876..534440f 100755 --- a/build-base-k8s-jenkins-agent.sh +++ b/build-base-k8s-jenkins-agent.sh @@ -87,4 +87,6 @@ docker build \ -f k8s-jenkins-agent/Dockerfile \ $last_arg -docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION +if [[ $PUSH_AGENT != "false" ]] ; then + docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION +fi diff --git a/build-base-k8s-jenkins-coverage-agent.sh b/build-base-k8s-jenkins-coverage-agent.sh new file mode 100755 index 0000000..3c8aa35 --- /dev/null +++ b/build-base-k8s-jenkins-coverage-agent.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +./build-edt.sh + +export PUSH_AGENT='false' +./build-base-k8s-jenkins-agent.sh + +docker build \ + --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg BASE_IMAGE=base-jenkins-agent \ + --build-arg BASE_TAG=$ONEC_VERSION \ + --build-arg EDT_VERSION=$EDT_VERSION \ + --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ + -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ + -f coverage41C/Dockerfile \ + $last_arg + +docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION diff --git a/build-base-swarm-jenkins-agent.bat b/build-base-swarm-jenkins-agent.bat index b010bc2..b9d1c41 100644 --- a/build-base-swarm-jenkins-agent.bat +++ b/build-base-swarm-jenkins-agent.bat @@ -10,7 +10,6 @@ if %ERRORLEVEL% neq 0 goto end if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") - docker build ^ --pull ^ --build-arg DOCKER_REGISTRY_URL=library ^ @@ -95,9 +94,11 @@ docker build ^ if %ERRORLEVEL% neq 0 goto end -docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION% +IF NOT "%PUSH_AGENT%"=="false" ( + docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION% +) if %ERRORLEVEL% neq 0 goto end :end -echo End of program. \ No newline at end of file +echo End of program. diff --git a/build-base-swarm-jenkins-agent.sh b/build-base-swarm-jenkins-agent.sh index 5517ddc..96142e7 100755 --- a/build-base-swarm-jenkins-agent.sh +++ b/build-base-swarm-jenkins-agent.sh @@ -87,4 +87,6 @@ docker build \ -f swarm-jenkins-agent/Dockerfile \ $last_arg -docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION +if [[ $PUSH_AGENT != "false" ]] ; then + docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION +fi diff --git a/build-base-swarm-jenkins-coverage-agent.bat b/build-base-swarm-jenkins-coverage-agent.bat new file mode 100644 index 0000000..425df1f --- /dev/null +++ b/build-base-swarm-jenkins-coverage-agent.bat @@ -0,0 +1,29 @@ +@echo off + +docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% + +if %ERRORLEVEL% neq 0 goto end + +if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af + +if %ERRORLEVEL% neq 0 goto end + +if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") + +.\build-edt-swarm-agent.bat + +set PUSH_AGENT='false' +.\build-base-swarm-jenkins-agent.bat + +docker build ^ + --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ + --build-arg BASE_IMAGE=base-jenkins-agent ^ + --build-arg BASE_TAG=%ONEC_VERSION% ^ + --build-arg EDT_VERSION=%EDT_VERSION% ^ + --build-arg COVERAGE41C_VERSION=%COVERAGE41C_VERSION% ^ + -t %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% ^ + -f coverage41C/Dockerfile ^ + %last_arg% + +docker push %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% + diff --git a/build-base-swarm-jenkins-coverage-agent.sh b/build-base-swarm-jenkins-coverage-agent.sh new file mode 100755 index 0000000..2055470 --- /dev/null +++ b/build-base-swarm-jenkins-coverage-agent.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +./build-edt.sh + +export PUSH_AGENT='false' +./build-base-swarm-jenkins-agent.sh + +docker build \ + --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg BASE_IMAGE=base-jenkins-agent \ + --build-arg BASE_TAG=$ONEC_VERSION \ + --build-arg EDT_VERSION=$EDT_VERSION \ + --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ + -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ + -f coverage41C/Dockerfile \ + $last_arg + +docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION diff --git a/build-edt-k8s-agent.sh b/build-edt-k8s-agent.sh index 92929f6..408f0a0 100755 --- a/build-edt-k8s-agent.sh +++ b/build-edt-k8s-agent.sh @@ -14,15 +14,6 @@ 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 .' @@ -31,29 +22,7 @@ fi edt_version=$EDT_VERSION edt_escaped="${edt_version// /_}" -docker build \ - --pull \ - $no_cache_arg \ - --build-arg DOCKER_REGISTRY_URL=library \ - --build-arg BASE_IMAGE=ubuntu \ - --build-arg BASE_TAG=20.04 \ - --build-arg ONESCRIPT_PACKAGES="yard" \ - -t $DOCKER_REGISTRY_URL/oscript-downloader:latest \ - -f oscript/Dockerfile \ - $last_arg - -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 \ - -t $DOCKER_REGISTRY_URL/edt:$edt_escaped \ - -f edt/Dockerfile \ - $last_arg +./build-edt.sh docker build \ --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ diff --git a/build-edt-swarm-agent.bat b/build-edt-swarm-agent.bat index 672afde..1f3f6b7 100644 --- a/build-edt-swarm-agent.bat +++ b/build-edt-swarm-agent.bat @@ -8,46 +8,12 @@ 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 - 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 ^ - --build-arg BASE_IMAGE=ubuntu ^ - --build-arg BASE_TAG=20.04 ^ - --build-arg ONESCRIPT_PACKAGES="yard" ^ - -t %DOCKER_REGISTRY_URL%/oscript-downloader:latest ^ - -f oscript/Dockerfile ^ - %last_arg% - -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 ^ - -t %DOCKER_REGISTRY_URL%/onec-client:%edt_escaped% ^ - -f edt/Dockerfile ^ - %last_arg% - -if %ERRORLEVEL% neq 0 goto end +.\build-edt.bat docker build ^ --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ diff --git a/build-edt-swarm-agent.sh b/build-edt-swarm-agent.sh index fbc6941..95d4a0d 100755 --- a/build-edt-swarm-agent.sh +++ b/build-edt-swarm-agent.sh @@ -14,15 +14,6 @@ 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 .' @@ -31,29 +22,7 @@ fi edt_version=$EDT_VERSION edt_escaped="${edt_version// /_}" -docker build \ - --pull \ - $no_cache_arg \ - --build-arg DOCKER_REGISTRY_URL=library \ - --build-arg BASE_IMAGE=ubuntu \ - --build-arg BASE_TAG=20.04 \ - --build-arg ONESCRIPT_PACKAGES="yard" \ - -t $DOCKER_REGISTRY_URL/oscript-downloader:latest \ - -f oscript/Dockerfile \ - $last_arg - -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 \ - -t $DOCKER_REGISTRY_URL/edt:$edt_escaped \ - -f edt/Dockerfile \ - $last_arg +./build-edt.sh docker build \ --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ diff --git a/build-edt.bat b/build-edt.bat new file mode 100644 index 0000000..2243f6b --- /dev/null +++ b/build-edt.bat @@ -0,0 +1,51 @@ +@echo off + +docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% + +if %ERRORLEVEL% neq 0 goto end + +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 + +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 ^ + --build-arg BASE_IMAGE=ubuntu ^ + --build-arg BASE_TAG=20.04 ^ + --build-arg ONESCRIPT_PACKAGES="yard" ^ + -t %DOCKER_REGISTRY_URL%/oscript-downloader:latest ^ + -f oscript/Dockerfile ^ + %last_arg% + +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 ^ + -t %DOCKER_REGISTRY_URL%/onec-client:%edt_escaped% ^ + -f edt/Dockerfile ^ + %last_arg% + +if %ERRORLEVEL% neq 0 goto end + diff --git a/build-edt.sh b/build-edt.sh new file mode 100755 index 0000000..a520bcd --- /dev/null +++ b/build-edt.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +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 .' +fi + +edt_version=$EDT_VERSION +edt_escaped="${edt_version// /_}" + +docker build \ + --pull \ + $no_cache_arg \ + --build-arg DOCKER_REGISTRY_URL=library \ + --build-arg BASE_IMAGE=ubuntu \ + --build-arg BASE_TAG=20.04 \ + --build-arg ONESCRIPT_PACKAGES="yard" \ + -t $DOCKER_REGISTRY_URL/oscript-downloader:latest \ + -f oscript/Dockerfile \ + $last_arg + +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 \ + -t $DOCKER_REGISTRY_URL/edt:$edt_escaped \ + -f edt/Dockerfile \ + $last_arg diff --git a/coverage41C/Dockerfile b/coverage41C/Dockerfile new file mode 100644 index 0000000..5994eb3 --- /dev/null +++ b/coverage41C/Dockerfile @@ -0,0 +1,25 @@ +ARG DOCKER_REGISTRY_URL=library +ARG BASE_IMAGE=edt +ARG BASE_TAG +ARG EDT_VERSION=2021.3 +ARG COVERAGE41C_VERSION=2.7.2 +ARG EDT_PLUGINS=/opt/1C/1CE/components/1c-edt-${EDT_VERSION}*-x86_64/plugins + +FROM ${DOCKER_REGISTRY_URL}/edt:${EDT_VERSION} as base + +FROM ${DOCKER_REGISTRY_URL}/${BASE_IMAGE}:${BASE_TAG} +LABEL maintainer="Dima Ovcharenko , Korus Consulting LLC" + +ARG COVERAGE41C_VERSION +ARG EDT_PLUGINS + +COPY --from=base ${EDT_PLUGINS}/com._1c.g5.v8.dt.debug.core_*.jar ${EDT_PLUGINS}/com._1c.g5.v8.dt.debug.model_*.jar /opt/1C/1CE/ + +ADD https://github.com/1c-syntax/Coverage41C/releases/download/v${COVERAGE41C_VERSION}/Coverage41C-${COVERAGE41C_VERSION}.tar \ + /opt/ + +RUN tar xf /opt/Coverage41C-${COVERAGE41C_VERSION}.tar -C /opt/ \ + && rm -rf /opt/Coverage41C-${COVERAGE41C_VERSION}.tar + +ENV EDT_LOCATION="/opt/1C/1CE/" +ENV PATH="/opt/Coverage41C-${COVERAGE41C_VERSION}/bin:$PATH"