Add configuration files and update project documentation

- Introduced .editorconfig for consistent coding styles across the project.
- Added .golangci.yml for Go linting configuration.
- Updated AGENTS.md to clarify project structure and components.
- Enhanced CONTRIBUTING.md with Makefile usage for common tasks.
- Updated Dockerfiles to use Go 1.24 and improved build instructions.
- Refined README.md and deployment documentation for clarity.
- Added testing documentation in testing.md for backend and frontend tests.
- Introduced Makefile for streamlined development commands and tasks.
This commit is contained in:
2026-03-01 01:51:47 +03:00
parent 0466ff3087
commit 6529d7370e
92 changed files with 13411 additions and 8438 deletions

View File

@@ -1,43 +1,49 @@
# Деплой
# Deployment
## Docker
Образ собирается из репозитория. Внутри контейнера приложение слушает порт **8080** и ожидает, что каталог данных смонтирован в `/map` (база и изображения гридов).
The image is built from the repository. Inside the container the application listens on port **8080** and expects the data directory to be mounted at `/map` (database and grid images).
Пример запуска:
Example run:
```bash
docker run -v /srv/hnh-map:/map -p 80:8080 andyleap/hnh-auto-mapper:v-4
docker run -v /srv/hnh-map:/map -p 80:8080 hnh-map
```
Или с переменными:
Or with environment variables:
```bash
docker run -v /srv/hnh-map:/map -p 8080:8080 \
-e HNHMAP_PORT=8080 \
-e HNHMAP_BOOTSTRAP_PASSWORD=your-secure-password \
andyleap/hnh-auto-mapper:v-4
hnh-map
```
Рекомендуется после первой настройки убрать или не передавать `HNHMAP_BOOTSTRAP_PASSWORD`.
It is recommended to remove or stop passing `HNHMAP_BOOTSTRAP_PASSWORD` after initial setup.
To build the image locally:
```bash
docker build -t hnh-map .
```
## OAuth (Google)
Для входа через Google OAuth:
To enable login via Google OAuth:
1. Создайте проект в [Google Cloud Console](https://console.cloud.google.com/).
2. Включите «Google+ API» / «Google Identity» и создайте OAuth 2.0 Client ID (тип «Web application»).
3. В настройках клиента добавьте Authorized redirect URI: `https://your-domain.com/map/api/oauth/google/callback` (замените на ваш домен).
4. Задайте переменные окружения:
1. Create a project in [Google Cloud Console](https://console.cloud.google.com/).
2. Enable "Google+ API" / "Google Identity" and create an OAuth 2.0 Client ID (type "Web application").
3. In the client settings, add the Authorized redirect URI: `https://your-domain.com/map/api/oauth/google/callback` (replace with your domain).
4. Set the following environment variables:
- `HNHMAP_OAUTH_GOOGLE_CLIENT_ID` — Client ID
- `HNHMAP_OAUTH_GOOGLE_CLIENT_SECRET` — Client Secret
- `HNHMAP_BASE_URL`полный URL приложения (например `https://map.example.com`) для формирования redirect_uri. Если не задан, берётся из `Host` и `X-Forwarded-*` заголовков.
- `HNHMAP_BASE_URL`full application URL (e.g. `https://map.example.com`) for forming the redirect_uri. If not set, it is derived from the `Host` and `X-Forwarded-*` headers.
## Reverse proxy
Разместите сервис за nginx, Traefik, Caddy и т.п. на нужном домене. Проксируйте весь трафик на порт 8080 контейнера (или тот порт, на котором слушает приложение). Приложение отдаёт SPA по корню `/` (/, /login, /profile, /admin и т.д.), API — по `/map/api/`, SSE `/map/updates`, тайлы — `/map/grids/`.
Place the service behind nginx, Traefik, Caddy, etc. on the desired domain. Proxy all traffic to port 8080 of the container (or whichever port the application is listening on). The application serves the SPA at root `/` (/, /login, /profile, /admin, etc.), the API at `/map/api/`, SSE at `/map/updates`, and tiles at `/map/grids/`.
## Обновление и бэкапы
## Updates and backups
- При обновлении образа сохраняйте volume с `/map`: в нём лежат `grids.db` и каталоги с тайлами.
- Регулярно делайте бэкапы каталога данных (и при необходимости экспорт через админку «Export»).
- When updating the image, preserve the volume at `/map`: it contains `grids.db` and tile image directories.
- Regularly back up the data directory (and use the admin panel "Export" feature if needed).