diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..59e7b06 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +target/ +node_modules/ +test-data/ +data/ +.env +.git/ +*.pmtiles +docs/ +scripts/ +CONTRIBUTING.md +LICENSE diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..edc7700 --- /dev/null +++ b/compose.yml @@ -0,0 +1,27 @@ +services: + atlas: + build: . + ports: + - "${ATLAS_EXTERNAL_PORT:-8080}:80" + volumes: + - ${ATLAS_DATA_DIR:-./test-data}:/data:ro + env_file: + - path: .env + required: false + environment: + - ATLAS_TILE_SOURCE=local + - ATLAS_TILE_DIR=/data + - ATLAS_GEOCODE_INDEX_DIR=/data/geocode-index + - ATLAS_LANDMARK_PATH=/data/landmarks.bin + - ATLAS_PLACES_PATH=/data/places.bin + - ATLAS_SEARCH_INDEX_DIR=/data/search-index + - ATLAS_ROUTE_DIR=/data + - ATLAS_OSM_DIR=/data/osm + - ATLAS_PUBLIC_URL=${ATLAS_PUBLIC_URL:-http://localhost:8080} + restart: unless-stopped + healthcheck: + test: ["CMD", "wget", "--spider", "-q", "http://localhost:3001/health"] + interval: 30s + timeout: 5s + retries: 3 + start_period: 10s diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7f6aa1b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,57 @@ +worker_processes auto; +error_log /var/log/nginx/error.log warn; +pid /tmp/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + tcp_nopush on; + keepalive_timeout 65; + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/wasm; + + upstream atlas_api { + server 127.0.0.1:3001; + } + + server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # API proxy + location /v1/ { + proxy_pass http://atlas_api; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /health { + proxy_pass http://atlas_api; + } + + location /metrics { + proxy_pass http://atlas_api; + } + + # Frontend — SPA fallback + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { + expires 30d; + add_header Cache-Control "public, immutable"; + } + } +}