Snipe-IT Docker Compose files
Docker Compose files to spin up an instance of Snipe-IT.
How to run
Add a COMPOSE_ENV
file and save its location as a shell variable along with the location where this repo lives, here for example /opt/containers/snipeit
plus all other variables. At env/fqdn_context.env.example you'll find an example environment file.
When everything's ready start Snipe-IT with Docker Compose, otherwise head down to Initial setup first.
Environment
export COMPOSE_DIR='/opt/containers/snipeit'
export COMPOSE_CTX='ux_vilnius'
export COMPOSE_PROJECT='snipeit-'"${COMPOSE_CTX}"
export COMPOSE_FILE="${COMPOSE_DIR}"'/compose.yaml'
export COMPOSE_ENV=<add accordingly>
Context
On your deployment machine create the necessary Docker context to connect to and control the Docker daemon on whatever target host you'll be using, for example:
docker context create fully.qualified.domain.name --docker 'host=ssh://root@fully.qualified.domain.name'
Pull
Pull images from Docker Hub verbatim.
docker compose --project-name "${COMPOSE_PROJECT}" --file "${COMPOSE_FILE}" --env-file "${COMPOSE_ENV}" --profile 'full' pull
Copy to target
Copy images to target Docker host, that is assuming you deploy to a machine that itself has no network route to reach Docker Hub or your private registry of choice. Copying in its simplest form involves a local docker save
and a remote docker load
. Consider the helper mini-project quico.space/Quico/copy-docker where copy-docker.sh allows the following workflow:
export $(grep -Pi -- '.*?VERSION=' "${COMPOSE_ENV}")
for image in 'snipe/snipe-it:'"${SNIPEIT_VERSION}" 'mysql:'"${MYSQL_VERSION}"; do
copy-docker "${image}" fully.qualified.domain.name
done
Start
docker --context 'fully.qualified.domain.name' compose --project-name "${COMPOSE_PROJECT}" --file "${COMPOSE_FILE}" --env-file "${COMPOSE_ENV}" --profile 'full' up --detach
Initial setup
We're assuming you run Docker Compose workloads with ZFS-based bind mounts. ZFS management, creating a zpool and setting adequate properties for its datasets is out of scope of this document.
Datasets
Create ZFS datasets and set permissions as needed.
-
Parent dateset
export "$(grep -Pi -- '^CONTEXT=' "${COMPOSE_ENV}")" zfs create -o canmount=off zpool/data/opt zfs create -o mountpoint=/opt/docker-data zpool/data/opt/docker-data
-
Container-specific datasets
zfs create -p 'zpool/data/opt/docker-data/snipeit-'"${COMPOSE_CTX}"'/mysql/data' zfs create -p 'zpool/data/opt/docker-data/snipeit-'"${COMPOSE_CTX}"'/snipeit/data'
-
Change ownership
chown -R 999:999 '/opt/docker-data/snipeit-'"${COMPOSE_CTX}"'/mysql/data' chown -R 1000:1000 '/opt/docker-data/snipeit-'"${COMPOSE_CTX}"'/snipeit/data'
Additional files
None. You can start Snipe-IT right up and do not need to place any config file in any of the above-mentioned dirs. Per snipe-it.readme.io/docs/docker initial config happens inside the Snipe-IT container by first generating an app key via php artisan key:generate --show
. Follow that guide for more details.
When done head back up to How to run.
Development
Conventional commits
This project uses Conventional Commits for its commit messages.
Commit types
Commit types besides fix
and feat
are:
refactor
: Keeping functionality while streamlining or otherwise improving function flowdocs
: Documentation for project or components
Commit scopes
The following scopes are known for this project. A Conventional Commits commit message may optionally use one of the following scopes or none:
snipeit
: A change to how thesnipeit
service component worksmysql
: A change to how themysql
service component worksbuild
: Build-related changes such asDockerfile
fixes and features.mount
: Volume or bind mount-related changes.net
: Networking, IP addressing, routing changesmeta
: Affects the project's repo layout, file names etc.