feat(meta): Initial commit
This commit is contained in:
parent
22cfc246f2
commit
e2b5bb3b84
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.idea
|
109
README.md
109
README.md
@ -1,3 +1,108 @@
|
|||||||
# snipeit
|
# Snipe-IT Docker Compose files
|
||||||
|
|
||||||
Setup instructions for a Snipe-IT Docker container
|
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](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](#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](https://quico.space/Quico/copy-docker) where [copy-docker.sh](https://quico.space/Quico/copy-docker/src/branch/main/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](https://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](#how-to-run).
|
||||||
|
|
||||||
|
# Development
|
||||||
|
|
||||||
|
## Conventional commits
|
||||||
|
|
||||||
|
This project uses [Conventional Commits](https://www.conventionalcommits.org/) for its commit messages.
|
||||||
|
|
||||||
|
### Commit types
|
||||||
|
|
||||||
|
Commit _types_ besides `fix` and `feat` are:
|
||||||
|
|
||||||
|
- `refactor`: Keeping functionality while streamlining or otherwise improving function flow
|
||||||
|
- `docs`: 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:
|
||||||
|
|
||||||
|
- `snip eit`: A change to how the `snipeit` service component works
|
||||||
|
- `mysql`: A change to how the `mysql` service component works
|
||||||
|
- `build`: Build-related changes such as `Dockerfile` fixes and features.
|
||||||
|
- `mount`: Volume or bind mount-related changes.
|
||||||
|
- `net`: Networking, IP addressing, routing changes
|
||||||
|
- `meta`: Affects the project's repo layout, file names etc.
|
||||||
|
11
common-settings.yaml
Normal file
11
common-settings.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
common-settings:
|
||||||
|
environment:
|
||||||
|
TZ: "${TIMEZONE:-Etc/UTC}"
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "10"
|
||||||
|
compress: "true"
|
||||||
|
restart: "${RESTARTPOLICY:-unless-stopped}"
|
84
compose.yaml
Normal file
84
compose.yaml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
services:
|
||||||
|
snipeit:
|
||||||
|
image: "snipe/snipe-it:${SNIPEIT_VERSION}"
|
||||||
|
container_name: "snipeit-snipeit-${CONTEXT}"
|
||||||
|
networks:
|
||||||
|
snipeit-default:
|
||||||
|
profiles: ["full", "snipeit"]
|
||||||
|
ulimits:
|
||||||
|
nproc: ${ULIMIT_NPROC:-65535}
|
||||||
|
nofile:
|
||||||
|
soft: ${ULIMIT_NPROC:-65535}
|
||||||
|
hard: ${ULIMIT_NPROC:-65535}
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
extends:
|
||||||
|
file: common-settings.yaml
|
||||||
|
service: common-settings
|
||||||
|
ports:
|
||||||
|
- ${SNIPEIT_PORT}:80
|
||||||
|
volumes:
|
||||||
|
- /opt/docker-data/snipeit-${CONTEXT}/snipeit/data:/var/lib/snipeit
|
||||||
|
environment:
|
||||||
|
APP_ENV: ${APP_ENV}
|
||||||
|
APP_KEY: ${APP_KEY}
|
||||||
|
APP_LOCALE: ${APP_LOCALE}
|
||||||
|
APP_TIMEZONE: ${APP_TIMEZONE}
|
||||||
|
APP_TRUSTED_PROXIES: ${APP_TRUSTED_PROXIES}
|
||||||
|
APP_URL: ${APP_URL}
|
||||||
|
MAIL_ENV_ENCRYPTION: ${MAIL_ENV_ENCRYPTION}
|
||||||
|
MAIL_ENV_FROM_ADDR: ${MAIL_ENV_FROM_ADDR}
|
||||||
|
MAIL_ENV_FROM_NAME: ${MAIL_ENV_FROM_NAME}
|
||||||
|
MAIL_ENV_PASSWORD: ${MAIL_ENV_PASSWORD}
|
||||||
|
MAIL_ENV_USERNAME: ${MAIL_ENV_USERNAME}
|
||||||
|
MAIL_PORT_587_TCP_ADDR: ${MAIL_PORT_587_TCP_ADDR}
|
||||||
|
MAIL_PORT_587_TCP_PORT: ${MAIL_PORT_587_TCP_PORT}
|
||||||
|
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||||
|
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||||
|
MYSQL_PORT_3306_TCP_ADDR: ${MYSQL_PORT_3306_TCP_ADDR}
|
||||||
|
MYSQL_USER: ${MYSQL_USER}
|
||||||
|
PHP_UPLOAD_LIMIT: ${PHP_UPLOAD_LIMIT}
|
||||||
|
SECURE_COOKIES: ${SECURE_COOKIES}
|
||||||
|
APP_DEBUG: ${APP_DEBUG}
|
||||||
|
mysql:
|
||||||
|
image: "mysql:${MYSQL_VERSION}"
|
||||||
|
container_name: "snipeit-mysql-${CONTEXT}"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "--protocol", "tcp", "-h", "127.0.0.1"]
|
||||||
|
interval: 3s
|
||||||
|
timeout: 1s
|
||||||
|
retries: 20
|
||||||
|
start_period: 2s
|
||||||
|
networks:
|
||||||
|
snipeit-default:
|
||||||
|
profiles: ["full", "mysql"]
|
||||||
|
ulimits:
|
||||||
|
nproc: ${ULIMIT_NPROC:-65535}
|
||||||
|
nofile:
|
||||||
|
soft: ${ULIMIT_NPROC:-65535}
|
||||||
|
hard: ${ULIMIT_NPROC:-65535}
|
||||||
|
extends:
|
||||||
|
file: common-settings.yaml
|
||||||
|
service: common-settings
|
||||||
|
ports:
|
||||||
|
- ${MYSQL_PORT}:3306
|
||||||
|
volumes:
|
||||||
|
- /opt/docker-data/snipeit-${CONTEXT}/mysql/data:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||||
|
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||||
|
MYSQL_ROOT_HOST: ${MYSQL_ROOT_HOST}
|
||||||
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||||
|
MYSQL_USER: ${MYSQL_USER}
|
||||||
|
# command: mysqld --sql_mode=""
|
||||||
|
networks:
|
||||||
|
snipeit-default:
|
||||||
|
name: snipeit-${CONTEXT}
|
||||||
|
driver: bridge
|
||||||
|
driver_opts:
|
||||||
|
com.docker.network.enable_ipv6: "false"
|
||||||
|
ipam:
|
||||||
|
driver: default
|
||||||
|
config:
|
||||||
|
- subnet: ${SUBNET}
|
32
env/fqdn_context.env.example
vendored
Normal file
32
env/fqdn_context.env.example
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# This file is maintained by remco and populated with data from HashiCorp
|
||||||
|
# Vault. Changes not done in Vault will be reverted when file gets rendered.
|
||||||
|
|
||||||
|
APP_ENV=production
|
||||||
|
APP_KEY=base64:your-app-key-here
|
||||||
|
APP_LOCALE=en
|
||||||
|
APP_TIMEZONE=Etc/UTC
|
||||||
|
APP_TRUSTED_PROXIES=172.16.0.0/12
|
||||||
|
APP_URL=https://fully.qualified.domain.name
|
||||||
|
CONTEXT=ux_vilnius
|
||||||
|
MAIL_ENV_ENCRYPTION=tls
|
||||||
|
MAIL_ENV_FROM_ADDR=mail@example.com
|
||||||
|
MAIL_ENV_FROM_NAME=Asset Management
|
||||||
|
MAIL_ENV_PASSWORD=my-mail-env-password
|
||||||
|
MAIL_ENV_USERNAME=mail@example.com
|
||||||
|
MAIL_PORT_587_TCP_ADDR=smtp.example.com
|
||||||
|
MAIL_PORT_587_TCP_PORT=587
|
||||||
|
MYSQL_DATABASE=snipeit
|
||||||
|
MYSQL_PASSWORD=my-mysql-user-password
|
||||||
|
MYSQL_PORT=61001
|
||||||
|
MYSQL_PORT_3306_TCP_ADDR=mysql
|
||||||
|
MYSQL_ROOT_HOST=172.30.95.1
|
||||||
|
MYSQL_ROOT_PASSWORD=my-mysql-root-password
|
||||||
|
MYSQL_USER=snipeit
|
||||||
|
MYSQL_VERSION=latest
|
||||||
|
PHP_UPLOAD_LIMIT=100
|
||||||
|
SECURE_COOKIES=true
|
||||||
|
SNIPEIT_PORT=61000
|
||||||
|
SNIPEIT_VERSION=latest
|
||||||
|
SUBNET=172.30.95.0/24
|
||||||
|
# Set to true when needed for temporary debugging
|
||||||
|
APP_DEBUG=false
|
Loading…
x
Reference in New Issue
Block a user