I
I
Igor2019-09-30 14:18:20
Docker
Igor, 2019-09-30 14:18:20

Docker-compose auto installation project?

Colleagues, good afternoon!
I'm interested in the question.
The question is related to the automatic installation of the project.
For example, I need to hand over the project to someone for further development.
Before that, it was like this, the performer performed the installation and configuration of the project with pens.
Naturally, all this is in docker-compose.
I want to automate the process.
For example like this:
Power Shell (if Linux containers under windows)

clear
echo "Starting installation..."
echo "---------------------------------"
docker-compose -f dc.dev.yml build
Start-sleep 1

echo ""
echo "Starting..."
docker-compose -f dc.dev.yml up -d
Start-sleep 1


# APP
echo ""
echo "Dependency installation..."
echo "---------------------------------"
docker exec -i rosinter.app composer install
Start-sleep 3

echo ""
docker exec -i rosinter.app php bin/console about
Start-sleep 5


echo ""
echo "Creating a database schema..."
echo "---------------------------------"
docker exec -i rosinter.app php bin/console doctrine:schema:create
Start-sleep 3


echo ""
echo "Restoring data from dump files..."
echo "---------------------------------"
docker exec -i rosinter.db sh -c 'exec mysql -uroot -prk3kw1UDdqOEF4L1pmNkcyQ2oL rosinter < var/mysql/dumps/dump.sql'

echo ""
echo "-------------------------------------"
echo "Installation completed successfully!"
echo "-------------------------------------"

How true is the strategy, if you can call it that?
What profit do I want to get?
1. I give a link to the repository
2. The dude downloads the project
3. Runs the script
4. Everything works
Without additional gestures.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2019-09-30
@fox_12

It is better if scripts inside containers do this.
For example, how a simple Python script starts

#!/bin/bash

VENV=./rvenv
# если нет виртуального окружения - создаем его
if [ ! -d $VENV ]; then
    virtualenv -p `which python3` $VENV
    $VENV/bin/pip install -U pip
fi

# устанавливаем/доустанавливаем нужные пакеты
$VENV/bin/pip install -r requirements.txt

# делаем миграции
$VENV/bin/python src/manage.py migrate

# ждем пока контейнер с фронтом соберет библиотеки с помощью webpack
sleep 5

while [ -f ./build_stat.flag ];
do
    sleep 1;
    echo "Wait for webpack"
done;

# собираем статику
$VENV/bin/python src/manage.py collectstatic --no-input


$VENV/bin/uwsgi --yaml ./src/uwsgi.yml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question