# Brick Tracker

<https://gitea.baerentsen.space/FrederikBaerentsen/BrickTracker/src/branch/master/docs/quickstart.md>

## Update

```bash
scp active/container_bricktracker/connorbricktracker-compose.yaml bricktracker:
ssh bricktracker
docker compose -f connorbricktracker-compose.yaml up -d
```

## Setup

### Create the bricktracker user

```bash
# SSH into your podman server as root
useradd bricktracker
loginctl enable-linger $(id -u bricktracker)
systemctl --user --machine=bricktracker@.host enable podman-restart
systemctl --user --machine=bricktracker@.host enable --now podman.socket
mkdir -p /home/bricktracker/.config/containers/systemd
```

### Configure App

1. Copy the `.env.sample` from <https://gitea.baerentsen.space/FrederikBaerentsen/BrickTracker/src/branch/master/.env.sample> to `.env`
2. Set the following:
   1. `BK_AUTHENTICATION_PASSWORD`
   2. `BK_AUTHENTICATION_KEY`
   3. `BK_DATABASE_PATH`
   4. `BK_INSTRUCTIONS_FOLDER`
   5. `BK_MINIFIGURES_FOLDER`
   6. `BK_PARTS_FOLDER`
   7. `BK_REBRICKABLE_API_KEY`
   8. `BK_SETS_FOLDER`
3. Create the docker compose yaml

    ```yaml
    services:
    bricktracker:
        container_name: BrickTracker
        restart: unless-stopped
        image: gitea.baerentsen.space/frederikbaerentsen/bricktracker:1.3.1
        ports:
        - "3333:3333"
        volumes:
        - ./data:/var/lib/bricktracker
        - ./static/instructions:/app/static/instructions
        - ./static/minifigures:/app/static/minifigures
        - ./static/parts:/app/static/parts
        - ./static/sets:/app/static/sets
        env_file: ".env"
    ```

4. Start the service: `docker compose up -d`

## Caddy

1. Create the new DNS record for your website
2. Create the Caddyfile at `./Caddyfile`

    ```conf
    https://connors-legos.reeseapps.com:443 {
        reverse_proxy 127.0.0.1:3333
    }
    ```

3. Create the Caddy compose.yaml

    ```yaml
    services:
    caddy:
        image: caddy:<version>
        restart: unless-stopped
        ports:
        - "80:80"
        - "443:443"
        - "443:443/udp"
        volumes:
        - ./Caddyfile:/etc/caddy/Caddyfile
        - caddy_data:/data
        - caddy_config:/config

    volumes:
    caddy_data:
    caddy_config:
    ```
