snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.28k stars 3.05k forks source link

Update in docker environmentt #12259

Open MANS0FT opened 1 year ago

MANS0FT commented 1 year ago

Debug mode

Describe the bug

updating the environment based on the instructions below leads to a number of errors and makes it impossible to perform the update

https://snipe-it.readme.io/docs/upgrading https://snipe-it.readme.io/docs/docker

Reproduction steps

1. Snipe-IT installation, stop old container, delete image, change docker-compose file (add e.g. :v6.0.14), run environment after that it will re-pull the latest Snipe-IT image version, Launching the new container, but connecting to the same storage volume.

  1. docker exec container_name php artisan migrate --force Nothing to migrate.

Every time "noting to migrate..." and footer with version number is not changing

  1. so trying this way

docker exec container_name composer install --no-dev --prefer-source

get multiple: Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 0 installs, 0 updates, 28 removals

In GitDownloader.php line 246:

Failed to execute git show-ref --head -d

fatal: unsafe repository ('/var/www/html/vendor/theseer/tokenizer' is owned by someone else) To add an exception for this directory, call:

    git config --global --add safe.directory /var/www/html/vendor/theseer/toke

nizer

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [...]

so... docker exec container_name git config --global --add safe.directory /var/www/html/vendor/theseer/token... etc..

after that.... one more time: docker exec container_name composer install --no-dev --prefer-source

Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 0 installs, 0 updates, 5 removals

and

RUNING: docker exec container_name composer dump-autoload Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi Discovered Package: arietimmerman/laravel-scim-server Discovered Package: barryvdh/laravel-debugbar Discovered Package: barryvdh/laravel-dompdf Discovered Package: eduardokum/laravel-mail-auto-embed Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: fruitcake/laravel-cors Discovered Package: intervention/image Discovered Package: laravel/passport Discovered Package: laravel/slack-notification-channel Discovered Package: laravel/tinker Discovered Package: laravel/ui Discovered Package: laravelcollective/html Discovered Package: livewire/livewire Discovered Package: maatwebsite/excel Discovered Package: mediconesystems/livewire-datatables Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Discovered Package: pragmarx/google2fa-laravel Discovered Package: spatie/laravel-backup Discovered Package: unicodeveloper/laravel-password Package manifest generated successfully. @php artisan vendor:publish --force --tag=livewire:assets --ansi Copied Directory [/vendor/livewire/livewire/dist] To [/public/vendor/livewire] Publishing complete. Generated optimized autoload files containing 8507 classes

NOW running: docker exec container_name php artisan migrate --force even after cache clear etc..

still nothing to migrate... and version snipeIT in foother still the same... :(

How to upgrade SnipeIT in docker-compose env.???

Expected behavior

1. Snipe-IT installation, stop old container, delete image, change docker-compose file (add e.g. :v6.0.14), run environment after that it will re-pull the latest Snipe-IT image version, Launching the new container, but connecting to the same storage volume.

  1. docker exec container_name php artisan migrate --force Nothing to migrate.

Every time "noting to migrate..." and footer with version number is not changing

  1. so trying this way

docker exec container_name composer install --no-dev --prefer-source

get multiple: Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 0 installs, 0 updates, 28 removals

In GitDownloader.php line 246:

Failed to execute git show-ref --head -d

fatal: unsafe repository ('/var/www/html/vendor/theseer/tokenizer' is owned by someone else) To add an exception for this directory, call:

    git config --global --add safe.directory /var/www/html/vendor/theseer/toke

nizer

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [...]

so... docker exec container_name git config --global --add safe.directory /var/www/html/vendor/theseer/token... etc..

after that.... one more time: docker exec container_name composer install --no-dev --prefer-source

Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 0 installs, 0 updates, 5 removals

and

[root@sme sme]# docker exec itam.mansoft.com.pl_website composer dump-autoload Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi Discovered Package: arietimmerman/laravel-scim-server Discovered Package: barryvdh/laravel-debugbar Discovered Package: barryvdh/laravel-dompdf Discovered Package: eduardokum/laravel-mail-auto-embed Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: fruitcake/laravel-cors Discovered Package: intervention/image Discovered Package: laravel/passport Discovered Package: laravel/slack-notification-channel Discovered Package: laravel/tinker Discovered Package: laravel/ui Discovered Package: laravelcollective/html Discovered Package: livewire/livewire Discovered Package: maatwebsite/excel Discovered Package: mediconesystems/livewire-datatables Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Discovered Package: pragmarx/google2fa-laravel Discovered Package: spatie/laravel-backup Discovered Package: unicodeveloper/laravel-password Package manifest generated successfully. @php artisan vendor:publish --force --tag=livewire:assets --ansi Copied Directory [/vendor/livewire/livewire/dist] To [/public/vendor/livewire] Publishing complete. Generated optimized autoload files containing 8507 classes running: docker exec itam.mansoft.com.pl_website php artisan migrate

Screenshots

No response

Snipe-IT Version

latest

Operating System

RockyLinux (RedHat)

Web Server

docker official image

PHP Version

8

Operating System

No response

Browser

No response

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

No response

welcome[bot] commented 1 year ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

uberbrady commented 1 year ago

The whole premise of Docker is that we try and have the containers be somewhat 'disposable' - You should be able to chuck aside the old container, then spin up with a new one, and then you'll just be migrated to that new one. Even migrations, which happen to the database, not to the Snipe-IT app itself, should be handled since the "Docker entrypoint" runs migrations before starting the webserver.

Especially if you're discarding the old container, I find it a bit baffling that for some reason you keep picking up the old version and not the new one? Maybe you need to try docker pull snipe/snipe-it or something? If you type docker images do you see a relatively new-ish (by date) image for snipe/snipe-it?

MANS0FT commented 1 year ago

I agree 100% with what you wrote. In my case, only deleting the volume (website) allows you to get a new version of SNIPEIT - unfortunately, then I lose all attachments and image files.

Below is a snippet of my configuration.

itam.example.com_db:
      container_name: itam.example.com_db
      image: mariadb:latest
      command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
      restart: always
      env_file: snipeit/itam.example.com.env
      networks:
         - 'sme-tier'
      volumes:
         - 'itam.example.com_db:/var/lib/mysql'

   itam.example.com_website:
      container_name: itam.example.com_website
      image: snipe/snipe-it:v6.1.0-pre
;      image: snipe/snipe-it:v6.0.1
;      image: snipe/snipe-it:latest
      restart: always
      env_file: snipeit/itam.example.com.env
      networks:
         - 'sme-tier'
      ports:
         - 8001:80
      volumes:
         - 'itam.example.com_website:/var/www/html'
      depends_on:
         - itam.example.com_db
      links:
         - itam.example.com_db:itam

please help. In theory, it would be enough to just stop the containers, delete the containers, delete the images, make a change to the docker-composer file and run docker-composer

What could be the problem for me? env: docker 2.14; os RockyLinux;

MANS0FT commented 1 year ago

it worked . The problem was a bad volume (path) mount configuration. The data was written inside the container and the link was not visible from the docker host (outside)

One shot should explain everything. 2023-04-01_19h42_43

Should be:

      volumes:
         - 'itam.example.com_website:/var/lib/snipeit'
StarlessNights commented 1 year ago

I had a seemingly similar issue with the container not upgrading. I have some further builds on top of the basic image, and it turned out that docker compose doesn't rebuild on docker-compose up. https://github.com/docker/compose/issues/1487 This led to the old container being used.

So I just needed to add an explicit docker-compose build to my deployment script.