Merge pull request #1 from stevedylandev/chore/refactor-parcels-storage
4c780f39
chore: refactored parcels storage
7 file(s) · +9 −15
chore: refactored parcels storage
| 2731 | 2731 | ||
| 2732 | 2732 | [[package]] |
|
| 2733 | 2733 | name = "parcels" |
|
| 2734 | - | version = "0.1.1" |
|
| 2734 | + | version = "0.1.2" |
|
| 2735 | 2735 | dependencies = [ |
|
| 2736 | 2736 | "andromeda-auth", |
|
| 2737 | 2737 | "anyhow", |
| 1 | 1 | APP_PASSWORD=changeme |
|
| 2 | - | DATABASE_URL=sqlite://parcels.db |
|
| 2 | + | PARCELS_DB_PATH=parcels.db |
|
| 3 | 3 | USPS_CLIENT_ID=your_client_id_here |
|
| 4 | 4 | USPS_CLIENT_SECRET=your_client_secret_here |
|
| 5 | 5 | PORT=3000 |
| 1 | 1 | [package] |
|
| 2 | 2 | name = "parcels" |
|
| 3 | - | version = "0.1.1" |
|
| 3 | + | version = "0.1.2" |
|
| 4 | 4 | edition = "2024" |
|
| 5 | 5 | description = "Minimal package tracking" |
|
| 6 | 6 | license = "MIT" |
| 31 | 31 | ||
| 32 | 32 | FROM debian:bookworm-slim |
|
| 33 | 33 | RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* |
|
| 34 | - | WORKDIR /app |
|
| 35 | - | COPY --from=builder /app/target/release/parcels ./parcels |
|
| 34 | + | COPY --from=builder /app/target/release/parcels /usr/local/bin/parcels |
|
| 35 | + | WORKDIR /data |
|
| 36 | 36 | COPY --from=builder /app/apps/parcels/static ./static |
|
| 37 | - | COPY --from=builder /app/apps/parcels/templates ./templates |
|
| 38 | 37 | EXPOSE 3000 |
|
| 39 | - | CMD ["./parcels"] |
|
| 38 | + | CMD ["parcels"] |
| 25 | 25 | | Variable | Description | Default | |
|
| 26 | 26 | |---|---|---| |
|
| 27 | 27 | | `APP_PASSWORD` | Password for login authentication | *required* | |
|
| 28 | - | | `DATABASE_URL` | SQLite database path (e.g. `sqlite:///app/data/parcels.db`) | |
|
| 28 | + | | `PARCELS_DB_PATH` | SQLite database file path | `parcels.db` | |
|
| 29 | 29 | | `USPS_CLIENT_ID` | USPS OAuth2 client ID | *required* | |
|
| 30 | 30 | | `USPS_CLIENT_SECRET` | USPS OAuth2 client secret | *required* | |
|
| 31 | 31 | | `PORT` | Server port | `3000` | |
| 6 | 6 | ports: |
|
| 7 | 7 | - "3000:3000" |
|
| 8 | 8 | volumes: |
|
| 9 | - | - parcels_data:/app/data |
|
| 9 | + | - parcels_data:/data |
|
| 10 | 10 | env_file: |
|
| 11 | 11 | - .env |
|
| 12 | 12 | restart: unless-stopped |
| 60 | 60 | // ── Pool Setup ────────────────────────────────────────────────────────────── |
|
| 61 | 61 | ||
| 62 | 62 | pub fn database_path() -> String { |
|
| 63 | - | let raw = std::env::var("DATABASE_URL").unwrap_or_else(|_| "parcels.db".to_string()); |
|
| 64 | - | // Strip sqlite:// or sqlite:/// prefix if present |
|
| 65 | - | raw.strip_prefix("sqlite:///") |
|
| 66 | - | .or_else(|| raw.strip_prefix("sqlite://")) |
|
| 67 | - | .unwrap_or(&raw) |
|
| 68 | - | .to_string() |
|
| 63 | + | std::env::var("PARCELS_DB_PATH").unwrap_or_else(|_| "parcels.db".to_string()) |
|
| 69 | 64 | } |
|
| 70 | 65 | ||
| 71 | 66 | pub fn init_db(path: &str) -> Result<Db, DbError> { |