snipe / snipe-it

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

How to update from Docker v3.6.6 build 1 (gee2c67a) to v4? #4197

Closed ovizii closed 6 years ago

ovizii commented 7 years ago

I removed my old docker container (after backing everything vital up), pulled the latest snipe-it image, created a new container with exactly the same settings as the old container, started the container, visit my snipe-it dashboard and all I see is: Whoops, looks like something went wrong.

The error logs are similarly unhelpful:

 docker logs snipeit
Module ssl disabled.
To activate the new configuration, you need to run:
  service apache2 restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
Module ssl already disabled
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
Module ssl already disabled
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message

are there any instructions available for upgrading v3 to v4 via Docker image?

guy-tallon commented 7 years ago

https://snipe-it.readme.io/docs/upgrading-to-v4

I used the container ID to run the commands though I suspect you could (should?) just use the name as the ID changes.

docker container ls docker exec -i -t e35b33d1010 php artisan up

for example

ovizii commented 7 years ago

I had read that link but wasn't sure if it was necessary for the Docker image. Did you successfully upgrade your Docker installation of snipe-it by following those instructions? If you can confirm I'll go ahead and give them a try.

Found this, so not sure if simply executing stuff inside the container will be the right thing to do?

NOTE: Never run composer as a super-user or Administrator. Always run it as the user that owns the Snipe-IT files. Running composer as a super-user will break things in ways that will be difficult to debug later. Just don't do it.

Thanks for the reply :-)

guy-tallon commented 7 years ago

Yes, I successfully upgraded my docker by following those instructions 👍

The composer command(s) didn't run for me so I kind of avoided that. With the snipe and mysql data files on a local volume, it's trivial to back up so I just kept going. Made a typo the first time and just ran it again and currently have (obvious) errors in the logs and it's working fine.

I'm using Docker for Mac, so I don't know if it's a little different in other environments but, I did steps 1,3,4, (I pulled version 4.0.9 before hand docker pull snipe/snipe-it:v4.0.9), 7,9,10,11,12

If it doesn't work I can alway write down step by step what I did

ovizii commented 7 years ago

every step except step 11 is clear to me.

Here is how I run the docker image: docker run -d -p 9191:80 --name="snipeit" --restart=unless-stopped --env-file=/mnt/snipe-it/snipe-env -v /mnt/snipe-it:/var/lib/snipeit snipe/snipe-it

that seems to generate a .env file inside the container in /var/www/html but the details specified inside --env-file=/mnt/snipe-it/snipe-env are not reflected in there but seem to be passed onto mz container via env variables.

Sorry, I am lost here, hoping someone can help me sort this out, meanwhile back to the working version :-)

guy-tallon commented 7 years ago

Are you missing the link to the mysql database there? --link snipe-mysql:mysql

Also, in the docs it has the env file location after the mount. Perhaps that's all it is

docker run -d -p 9191:80 --name="snipeit" -v /mnt/snipe-it:/var/lib/snipeit --restart=unless-stopped --env-file=/mnt/snipe-it/snipe-env snipe/snipe-it

edit: Just noticed you said step 11. You run it the same way you did for the command in step 10. My first post there is how I did it. Got the container ID and then ran the php command

ovizii commented 7 years ago

Thanks furby you've been a great help so far. Let me clarify your questions:

I know how to edit the .env file inside the container, it just does not reflect the arguments I am passing to my container with --env-file=/mnt/snipe-it/snipe-env - the .env inside the container looks like this:

# --------------------------------------------
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
#APP_ENV=develop
#APP_DEBUG=false
#APP_KEY=Change_this_key_or_snipe_will_get_ya
#APP_URL=http://127.0.0.1:32782
#APP_TIMEZONE=US/Pacific
#APP_LOCALE=en

# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_HOST=${MYSQL_PORT_3306_TCP_ADDR}
DB_DATABASE=${MYSQL_DATABASE}
DB_USERNAME=${MYSQL_USER}
DB_PASSWORD=${MYSQL_PASSWORD}
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'

# --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
# --------------------------------------------
MAIL_DRIVER=smtp
MAIL_HOST=${MAIL_PORT_587_TCP_ADDR}
MAIL_PORT=${MAIL_PORT_587_TCP_PORT}
...

I decided to skip the --link snipe-mysql:mysql I access my mysql server differently, see my --env-file=/mnt/snipe-it/snipe-env for details.

Here comes my snipe-env file: image

And if I do a docker inspect snipeit-container I see in the env section that my details are indeed being used, just not in the .env file image

###edit### So sorry, I made a typo, I have a problem with step 10 not 11 :-( its all about this section:

open your .env file and add a new field called LEGACY_APP_KEY= and add your v3.x Snipe-IT APP_KEY value there.

I can see how this was confusing, my problem was editing a seemingly useless .env file. Does my thread now make more sense? I'm wondering what the point is of editing this file and how. there does not seem to be any text editor inside the container. How would I apply these edits to the snipe-env file so the changes end up inside the container?

guy-tallon commented 7 years ago

I'd written a longer post but, maybe just keep it simple. Copy the env file out to your host and copy it back?

dejaeghered commented 6 years ago

I just spun up a container following the documentation and I notice that the .env file in the container is not reflecting my data in the run --env-file. The mysql pdo is not working because of the incorrect template data inside the .env file. So its not just an upgrade issue but rather something missing with the latest v4 container not generating the .env file from the --env-file param. What script/code should be generating the .env file using docker?

dejaeghered commented 6 years ago

My issue was caused by a typo with the linking that caused env variables to be prefixed MYQL (typo) I ran the container with --link "snipe-mysql:myql"

HinchK commented 6 years ago

Updating your docker environment is stopping the old container and attaching the latest application instance onto your old database. The only step required is to update your old snipe-it database with the latest changes with: docker exec -i -t snipeit-latest php artisan migrate --force

Unfortunately, I've also noticed that my .env file did not load.! It wasn't until I inspected my container via docker inspect snipeit-latest to verify my .env settings in the container configuration that I was able to pin down what happened.

If you run into a Whoops! while trying to attach the latest snipe-it image:

First, migrate your database:

docker exec -i -t snipeit-latest php artisan migrate --force

Then run:

docker exec -i -t snipeit-latest php artisan clear-compiled
docker exec -i -t snipeit-latest php artisan cache:clear

To replace an erroneous previously compiled class file with the current, working settings you have passed in.

Here's my containers from testing (for reference):

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                           NAMES
bf2e00d0f6ee        snipe/snipe-it:latest   "/tini -- /entrypo..."   About an hour ago   Up 46 minutes       443/tcp, 0.0.0.0:8080->80/tcp   snipeit-latest
554560937ee3        mysql:5.6               "docker-entrypoint..."   2 hours ago         Up 2 hours          0.0.0.0:32768->3306/tcp         snipe-mysql

TLDR: If you run into an issue after migrating your database up with the latest version, check your container with docker inspect [container-id], make sure everything is in the right place (APP_KEY, DB_HOST, etc.). Then blast that stale cache with:

docker exec -i -t [container-id] php artisan clear-compiled
docker exec -i -t [container-id] php artisan cache:clear

Let me know if that doesn't work for you!

snipe commented 6 years ago

This is a duplicate of #4101, but this ticket has more info so keeping this one as primary.

We haven't heard back in a bit, so I'm going to close this ticket for now, but will re-open it if you're still having issues.

hackerman-hacking

ovizii commented 6 years ago

@HinchK you're the real deal ,-) I finally got around to do this migration and after following your last post in this thread I got it working. The only thing I need to add is that I kept seeing the "Whoops, looks like something went wrong." until I emptied my browser cache / tried a new browser.

Finally I'm also using the latest SnipeIT version!!!

Thanks to everyone else too who attempted to help me out here.