Files
snipe-it/docker
Brady Wetherington 22ea008bb4 New documentation on Docker method of running Snipe-IT. New environment
variables available to customize how Snipe-IT ought to work under
Docker. Locale, timezone, and custom-URL support. Documentation pushes
users to move more towards 'env-files' rather than environment variables.

Fixes #1020
2015-09-21 16:44:17 -07:00
..
2015-07-26 19:56:03 -07:00
2015-08-28 09:10:28 -07:00

How to use the Snipe-IT docker image

Build the snipeit image using the Dockerfile at the root directory of Snipe-IT by doing this:

docker build -t snipeit .

Then you can use your newly built image as snipeit

How to get up and running

  • The best way to handle all of the various settings for your various containers is to use an env-file. See the Docker documentation for more details. It should be just a simple text file with environment variable names and values, separated by = signs.

Your docker.env should look something like this:

# Mysql Parameters
MYSQL_ROOT_PASSWORD=YOUR_SUPER_SECRET_PASSWORD
MYSQL_DATABASE=snipeit
MYSQL_USER=snipeit
MYSQL_PASSWORD=YOUR_snipeit_USER_PASSWORD

# Email Parameters
# - the hostname/IP address of your mailserver
MAIL_PORT_587_TCP_ADDR=smtp.whatever.com
#the port for the mailserver (probably 587, could be another)
MAIL_PORT_587_TCP_PORT=587
# the default from address, and from name for emails
MAIL_ENV_FROM_ADDR=youremail@yourdomain.com
MAIL_ENV_FROM_NAME=Your Full Email Name
# - pick 'tls' for SMTP-over-SSL, 'tcp' for unencrypted
MAIL_ENV_ENCRYPTION=tcp
# SMTP username and password
MAIL_ENV_USERNAME=your_email_username
MAIL_ENV_PASSWORD=your_email_password

# Snipe-IT Settings
SNIPEIT_TIMEZONE=UTC
SNIPEIT_LOCALE=en
SERVER_URL=https://myserver.com
  • First get a MySQL container running
docker run --name snipe-mysql --env-file=my_env_file -d -p $(docker-machine ip b2d)::3306 mysql

That should set you up with your database to use. (You can also specify environment variables on the command-line instead of the env-file, but that can get very clunky very quickly; see docker run --help for details)

  • If your Email solution requires its own container, start that container or service. Make sure to expose port 587 for mail submission, and use --link mail:....

Now you can start your Snipe-IT container -

docker run -d -p $(docker-machine ip b2d)::80 --name="snipeit" --link snipe-mysql:mysql --env-file=my_env_file snipeit 

If you have a separate container running for email, you will also want a --link setting for email as well.

You can find out what port Snipe-IT is running on with:

docker port snipeit

And finally, you can initialize the application and database like this:

docker exec -i -t snipeit php artisan app:install

(Go ahead and answer the questions however you like. Type 'yes' when asked whether or not you want to run migrations.)

#NOTE:

You may have to run:

~~docker exec -i -t snipeit php artisan key:generate --env=production~~

to get the production application key set correctly; I'm not yet sure why this is (I think it's a bug?)

If you want to seed

You can load out some initial data into the DB if you like by doing this:

~~docker -p $(boot2docker ip):8000:80 --link mysql:mysql php artisan db:seed~~

This already happens

For Development

When you call docker run - make sure to mount your own snipe-it directory over the /var/www/html directory. Something like:

docker run -d -v /Path/To/My/snipe-it/checkout:/var/www/html -p $(boot2docker ip)::80  --name="snipeit" --link mysql:mysql snipeit

Then your local changes to the code will be reflected. You will have to re-run composer install -

docker exec -i -t snipeit composer install

You'll need to copy the docker/database.php file to app/config/production/ , and copy the app/config/production/app.example.php to app/config/production/app.php

And also app:install -

docker exec -i -t snipeit php artisan app:install

And you may still need to generate the key with -

docker exec -i -t snipeit php artisan key:generate --env=production

While you're developing, you may need to occasionally run -

docker exec snipeit composer dump-autoload

To fix the autoloading cache (if, for example, your class names change, or you add new ones...)