A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.
1version: '3.8'
2
3# Define reusable environment variables
4x-environment: &common-env
5 SERVER_HOST: 0.0.0.0
6 SERVER_PORT: 3000
7 RUST_LOG: info
8
9services:
10 app:
11 build:
12 context: .
13 dockerfile: Dockerfile
14 args:
15 # Build-time variables
16 VITE_API_URL: ${VITE_API_URL:-http://localhost:3000}
17 NODE_ENV: ${NODE_ENV:-production}
18 RUST_ENV: ${RUST_ENV:-release}
19 container_name: shortener-app
20 ports:
21 - "3000:3000"
22 environment:
23 <<: *common-env # Include common environment variables
24 DATABASE_URL: postgres://shortener:shortener123@db:5432/shortener
25 JWT_SECRET: ${JWT_SECRET:-your-secret-key-change-me-in-production}
26 depends_on:
27 db:
28 condition: service_healthy
29 restart: unless-stopped
30
31 db:
32 image: postgres:15-alpine
33 container_name: shortener-db
34 environment:
35 POSTGRES_DB: ${POSTGRES_DB:-shortener}
36 POSTGRES_USER: ${POSTGRES_USER:-shortener}
37 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-shortener123}
38 ports:
39 - "5432:5432"
40 volumes:
41 - shortener-data:/var/lib/postgresql/data
42 healthcheck:
43 test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-shortener}" ]
44 interval: 5s
45 timeout: 5s
46 retries: 5
47 restart: unless-stopped
48
49volumes:
50 shortener-data: