1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

(bug) fix #355 compatibility with the new docker-compose CLI

This commit is contained in:
Sylvain 2022-05-23 16:29:10 +02:00
parent dce1835028
commit 442f7e0453
6 changed files with 78 additions and 15 deletions

View File

@ -10,6 +10,7 @@
- Fix a bug: Missing of description of PlanCategory migration
- Fix a bug: Unable to create plans for all group
- Fix a bug: backPrevLocation button on Notification Center opens reset password page (#348)
- Fix a bug: compatibility with the new docker-compose CLI (#355)
- Fix a security issue: updated moment.js to 2.29.2. to fix [CVE-2022-24785](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24785)
- Fix a security issue: updated nokogiri to 1.13.6 to fix [CVE-2022-298240](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-298240)
- Fix a security issue: updated async to 2.6.4 to fix [CVE-2021-43138](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-43138)

View File

@ -106,7 +106,7 @@ In order to remove ElasticSearch, you must **first** disable the statistics modu
Then, you can remove the `elasticsearch` service from the [docker-compose.yml](../setup/docker-compose.yml) file and restart the whole application:
```bash
docker-compose down && docker-compose up -d
docker compose down && docker compose up -d
```
Disabling ElasticSearch will save up to 800 Mb of memory.
@ -118,11 +118,11 @@ Before using any of these commands, you must first `cd` into the app directory.
- Read again the environment variables and restart
```bash
docker-compose down && docker-compose up -d
docker compose down && docker compose up -d
```
- Open a bash prompt inside the app container
```bash
docker-compose exec fabmanager bash
docker compose exec fabmanager bash
```
- Open the ruby console in the application
```bash
@ -130,11 +130,11 @@ docker-compose exec fabmanager bash
```
- Show services status
```bash
docker-compose ps
docker compose ps
```
- Run a command and provide it environment variables
```bash
docker-compose run --rm -e VAR1=xxx -e VAR2=xxx fabmanager bundle exec rails my:command
docker compose run --rm -e VAR1=xxx -e VAR2=xxx fabmanager bundle exec rails my:command
```
<a name="update-fab-manager"></a>
## Update Fab-manager
@ -192,11 +192,11 @@ Then, you'll need to perform the upgrade with the following command:
2. Pull last docker images
`docker-compose pull`
`docker compose pull`
3. Stop the app
`docker-compose stop fabmanager`
`docker compose stop fabmanager`
4. Remove old assets
@ -204,7 +204,7 @@ Then, you'll need to perform the upgrade with the following command:
5. Compile new assets
`docker-compose run --rm fabmanager bundle exec rails assets:precompile`
`docker compose run --rm fabmanager bundle exec rails assets:precompile`
6. Run specific commands
@ -212,23 +212,23 @@ Then, you'll need to perform the upgrade with the following command:
are always specified in the [CHANGELOG](https://github.com/sleede/fab-manager/blob/master/CHANGELOG.md) and prefixed by **[TODO DEPLOY]**.
Those commands execute specific tasks and have to be run manually.
You must prefix the commands starting by `rails...` or `rake...` with: `docker-compose run --rm fabmanager bundle exec`.
You must prefix the commands starting by `rails...` or `rake...` with: `docker compose run --rm fabmanager bundle exec`.
In any other cases, the other commands (like those invoking curl `\curl -sSL... | bash`) must not be prefixed.
You can also ignore commands only applicable to development environnement, which are prefixed by `(dev)` in the CHANGELOG.
7. Restart all containers
```bash
docker-compose down
docker-compose up -d
docker compose down
docker compose up -d
```
You can check that all containers are running with `docker-compose ps`.
You can check that all containers are running with `docker compose ps`.
<a name="upgrade-to-the-last-version"></a>
### Upgrade to the last version
It's the default behaviour as `docker-compose pull` command will fetch the latest versions of the docker images.
It's the default behaviour as `docker compose pull` command will fetch the latest versions of the docker images.
Be sure to run all the specific commands listed in the [CHANGELOG](https://github.com/sleede/fab-manager/blob/master/CHANGELOG.md) between your actual, and the new version in sequential order.
__Example:__ to update from v2.4.0 to v2.4.3, you will run the specific commands for the v2.4.1, v2.4.2 and v2.4.3.

View File

@ -1,3 +1,18 @@
#!/usr/bin/env bash
docker-compose exec -T postgres psql -Upostgres -c \\dFd | head -n -2 | tail -n +3 | awk '{ print gensub(/([a-z]+)_stem/,"\\1","g",$3); }'
docker-compose()
{
if ! docker compose version 1>/dev/null 2>/dev/null
then
if ! \docker-compose version 1>/dev/null 2>/dev/null
then
echo -e "\e[91m[ ❌ ] docker-compose was not found, exiting...\e[39m" && exit 1
else
\docker-compose "$@"
fi
else
docker compose "$@"
fi
}
docker-compose exec -T postgres psql -Upostgres -c \\dFd | head -n -2 | tail -n +3 | awk '{ print gensub(/([a-z]+)_stem/,"\\1","g",$3); }'

View File

@ -8,6 +8,21 @@ config() {
SERVICE="$(yq eval '.services.*.image | select(. == "sleede/fab-manager*") | path | .[-2]' docker-compose.yml)"
}
docker-compose()
{
if ! docker compose version 1>/dev/null 2>/dev/null
then
if ! \docker-compose version 1>/dev/null 2>/dev/null
then
echo -e "\e[91m[ ❌ ] docker-compose was not found, exiting...\e[39m" && exit 1
else
\docker-compose "$@"
fi
else
docker compose "$@"
fi
}
run()
{
config

View File

@ -45,7 +45,7 @@ system_requirements()
fi
done
fi
local _commands=("sudo" "curl" "sed" "openssl" "docker" "docker-compose" "systemctl")
local _commands=("sudo" "curl" "sed" "openssl" "docker" "systemctl")
for _command in "${_commands[@]}"; do
echo "detecting $_command..."
if ! command -v "$_command"
@ -54,9 +54,26 @@ system_requirements()
echo -e "\e[91m[ ❌ ] $_command was not found, exiting...\e[39m" && exit 1
fi
done
echo "detecting docker-compose..."
docker-compose version
printf "\e[92m[ ✔ ] All requirements successfully checked.\e[39m \n\n"
}
docker-compose()
{
if ! docker compose version 1>/dev/null 2>/dev/null
then
if ! \docker-compose version 1>/dev/null 2>/dev/null
then
echo -e "\e[91m[ ❌ ] docker-compose was not found, exiting...\e[39m" && exit 1
else
\docker-compose "$@"
fi
else
docker compose "$@"
fi
}
is_root()
{
return $(id -u)

View File

@ -43,6 +43,21 @@ jq() {
docker run --rm -i -v "${PWD}:/data" imega/jq "$@"
}
docker-compose()
{
if ! docker compose version 1>/dev/null 2>/dev/null
then
if ! \docker-compose version 1>/dev/null 2>/dev/null
then
echo -e "\e[91m[ ❌ ] docker-compose was not found, exiting...\e[39m" && exit 1
else
\docker-compose "$@"
fi
else
docker compose "$@"
fi
}
# set $SERVICE and $YES_ALL
config()
{