servico_plugnotas_teste/buildImages.sh

86 lines
2.5 KiB
Bash
Raw Permalink Normal View History

2026-07-10 16:32:22 -03:00
# GERA AS IMAGENS QUE SERAO PUBLICADAS NO HUB DOCKER
#
# TODOS OS PROJETOS COMPARTILHAM DA MAJOR VERSION DA IMAGEM
# EMBORA INTERNAMENTE TENHA MINOR E PATCH VERSION DIFERENTES
#
# FORMATO MAJOR.MINOR.PATCH
#
# A IMAGEM LISTA APENAS A MAJOR VERSION COMEÇANDO DA v1
# OPCOES DE EXECUÇÃO - git clone prune
version=':v1' # Versão de Inicial
# BUILD IMAGE 1/7/2025 - Caso não aja o diretorio utils ou Models clone é compulsorio
# BUILD IMAGE 1/7/2025 - Identifica o comando se docker compose ou docker-compose
# BUILD IMAGE 1/7/2025 - Permite mudar a configuração do Dockerfile com argumentos
buildarg='INSTALL_GCC=false'
# Try to find the correct $DOCKER_COMPOSE_CMD command
if command -v docker-compose &> /dev/null; then
DOCKER_COMPOSE_CMD="docker-compose"
elif command -v docker &> /dev/null && docker compose version &> /dev/null; then
DOCKER_COMPOSE_CMD="docker compose"
else
echo "$DOCKER_COMPOSE_CMD is not installed."
exit 1
fi
clone() {
echo "VERSAO ATUAL CLASSES ACESSORIAS Exchange2 SoftGOModel"
$DOCKER_COMPOSE_CMD down
if [ -d "utils" ]; then
rm -rf utils
fi
if [ -d "Model" ]; then
rm -rf Model
fi
git clone git@github.com:desenvolvimentopsa/Exchange2.git utils/Exchange2
git clone git@github.com:desenvolvimentopsa/SoftGOModel.git Model
cd utils
find . -name "*.py" | xargs -I {} cp {} .
rm -rf Exchange2
cd ..
}
for arg in "$@"; do
if [ -n "$arg" ] && [ "$arg" == "git" ]; then
echo "VERSAO ATUAL SERVICO_TECNOSPEED DO GIT ${version}"
git stash
git pull
fi
done
if [ ! -d "utils" ] || [ ! -d "Model" ]; then
echo "DOWNLOAD CLASSES ACESSORIAS"
clone
else
for arg in "$@"; do
if [ -n "$arg" ] && [ "$arg" == "clone" ]; then
echo "DOWNLOAD CLASSES ACESSORIAS"
clone
fi
done
fi
for arg in "$@"; do
if [ -n "$arg" ] && [ "$arg" == "prune" ]; then
echo "REMOVER IMAGENS SERVICO_TECNOSPEED ${version}"
$DOCKER_COMPOSE_CMD down
docker image ls -q -f "reference=servico_tecnospeed-*${version}" | xargs -I {} docker image rm -f {}
docker system prune -f
fi
done
echo "GERAR IMAGENS SERVICO_TECNOSPEED ${version}"
echo "SERVICO_TECNOSPEED SERVICE"
cd src
cp ../utils/Exchange2.py ./utils
cp ../Model/sg_tecnospeed_models/*.py ./Models
echo servico_tecnospeed${version}
cd ..
docker build --build-arg ${buildarg} -t sg_servico_tecnospeed${version} .
rm -rf ./utils
rm -rf ./Model