Files
progcode/README.md
T
huncode 3a3b2bcfc0
Build and deploy / deploy (push) Successful in 16s
add simple admin service
2026-05-18 02:48:47 +03:00

88 lines
2.7 KiB
Markdown

ProgCode.Ru
===========
Structure:
- `web/` — Next.js application.
- `web/data/articles.json` — article data used by the site.
- `web/public/assets/illustrations/` — SVG illustrations and article covers.
- `web/public/assets/media/` — raster images used by the site.
- `web/scripts/buildDatabase.mjs` — refreshes article data and generated assets from local source files.
Useful commands:
```bash
cd ~/tmp/progcode/web
npm install
ADMIN_PORT=3333 npm run admin:posts
node scripts/buildDatabase.mjs
npm run dev -- --port 3000
npm run build
```
Local posts admin:
- run from `web/` with `npm run admin:posts`;
- open `http://127.0.0.1:3333`;
- it edits posts as Markdown and saves generated `contentHtml` to `web/data/articles.json`;
- uploaded files are stored in `web/public/assets/uploads/`;
- it lives in `local-admin/`, outside the Next.js app, and `.dockerignore` excludes it from Docker builds.
Docker static deploy:
```bash
docker build -t progcode:static .
docker run --rm -p 8080:8080 progcode:static
```
Swarm example:
```bash
DOMAIN=progcode.example.com IMAGE=registry.example.com/progcode:static \
docker stack deploy -c deploy/stack.example.yml progcode
```
Gitea Actions variables:
- `DOMAIN` — public host routed by Traefik.
- `IMAGE` — full image tag to build and deploy, for example `registry.example.com/progcode:latest`.
- `IMAGE_REPO` — optional alternative to `IMAGE`; the workflow will tag images as `${IMAGE_REPO}:${short_sha}`.
- `REGISTRY` — registry host for `docker login`.
- `STACK_NAME` — optional, defaults to `progcode`.
- `TRAEFIK_NETWORK` — optional, defaults to `traefik-public`.
- `TRAEFIK_ENTRYPOINT` — optional, defaults to `websecure`.
- `TRAEFIK_CERTRESOLVER` — optional, defaults to `le`.
- The workflow also pushes `${IMAGE_REPO}:latest` automatically.
Gitea Actions secrets:
- `REGISTRY_USERNAME`
- `REGISTRY_PASSWORD`
- `SWARM_MANAGER_HOST`
- `SWARM_SSH_USER`
- `SWARM_SSH_PORT` — optional, defaults to `22`.
The workflow follows the same SSH model as `ohuello`: the deploy SSH private key is not stored in Gitea secrets. It must be created on the Gitea runner host and mounted into job containers as `/root/.ssh:ro`, including `known_hosts`.
Example account or organization variables:
```text
REGISTRY=git.example.com
IMAGE_REPO=git.example.com/huncode/progcode
DOMAIN=progcode.example.com
STACK_NAME=progcode
TRAEFIK_NETWORK=traefik-public
TRAEFIK_ENTRYPOINT=websecure
TRAEFIK_CERTRESOLVER=le
```
Example account or organization secrets:
```text
REGISTRY_USERNAME=<gitea-user-or-token-user>
REGISTRY_PASSWORD=<gitea-token>
SWARM_MANAGER_HOST=<swarm-manager-origin-ip-or-ssh-host>
SWARM_SSH_USER=deploy
SWARM_SSH_PORT=22
```