Skip to content

Commit

Permalink
Merge pull request #21 from sajera/feature/RELEASE-1.0.9
Browse files Browse the repository at this point in the history
feature/RELEASE-1.0.9
  • Loading branch information
sajera authored Sep 26, 2022
2 parents de09b6d + 3697926 commit f4852fc
Show file tree
Hide file tree
Showing 15 changed files with 489 additions and 80 deletions.
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ DEBUG=true

# API local configuration
PORT=3636
HOST=0.0.0.0
HOST=localhost
ALLOW_DOMAINS=.

# Redis local configuration
REDIS_URL=redis://127.0.0.1:6379

# RabbitMQ local configuration
RABBITMQ_CHANNELS=1
RABBITMQ_QUEUE=PRERENDER
RABBITMQ_URL=amqp://127.0.0.1:5672

# Prerender local configuration
CHROME_DEBUGGING_PORT=9222
#CHROME_BIN ===== for local enw will take your Chrome automatically
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ RUN apk add --update-cache chromium && \
rm -rf /var/cache/apk/* /tmp/*

ENV DEBUG=false \
HOST=0.0.0.0 \
REDIS_URL="" \
RABBITMQ_URL="" \
CHROME_DEBUGGING_PORT=9222 \
CHROME_BIN=/usr/bin/chromium-browser \
CHROME_FLAGS="--no-sandbox,--headless,--disable-gpu,--remote-debugging-port=9222,--hide-scrollbars,--disable-dev-shm-usage"
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Before start development locally, please make sure you have installed [Chrome br

`npm run start:dev`

> NOTE Starting Redis on MAC using Brew `brew services start redis`

## Development using [Docker](https://www.docker.com/)
Please, take in mind, that the `Dockerfile` isn't for local usage. It exists to simplify inserting the app into complex infrastructures.
Expand All @@ -35,15 +34,21 @@ Deployment using `Dockerfile` require only `REDIS_URL`.

`REDIS_URL=` connection to Redis within your environment

`RABBITMQ_URL=` connection to RabbitMQ within your environment (optional)

> Defaults
- `PORT=3636`
- `DEBUG=false`
- `HOST=0.0.0.0`
- `ALLOW_DOMAINS=.`
- `CHROME_DEBUGGING_PORT=9222`
- `CHROME_FORWARD_HEADERS=true`
- `CHROME_BIN=/usr/bin/chromium-browser`
- `CHROME_FLAGS=--no-sandbox,--headless,--disable-gpu,--remote-debugging-port=9222,--hide-scrollbars,--disable-dev-shm-usage`
- `REDIS_URL=`
- `RABBITMQ_URL=`
- `RABBITMQ_CHANNELS=1`
- `RABBITMQ_QUEUE=PRERENDER`


---
### API
Expand All @@ -52,13 +57,18 @@ Deployment using `Dockerfile` require only `REDIS_URL`.
- `curl 'http://localhost:3636/health'`
- `{ status: "UP" | "DOWN" }`

- Will render URL in `Chrome` browser then return `HTML` only the first time. After providing `HTML` content from the cache.
- Will render URL in `Chromium` browser then return `HTML` only the first time. After that, provide `HTML` content from the cache.
- **GET /render**
- `curl 'http://localhost:3636/render?url=http://example.com/'`

- Force reset cache and render url in `Chrome` browser then return `html`.
- Force reset the cache and render URL in `Chromium` browser, returns `HTML`.
- **GET /refresh**
- `curl 'http://localhost:3636/refresh?url=http://example.com/'`
- Optional query `ignoreResults=true` to avoid html results

- Force reset the cache and render URLs in `Chromium` browser
- **POST /refresh**
- `curl 'http://localhost:3636/refresh' -X 'POST' --data-raw '["not a link","http://example.com/","http://example.com/"]'`

- Will get URL `HTML` content from the cache.
- **GET /cached**
Expand All @@ -68,3 +78,17 @@ Deployment using `Dockerfile` require only `REDIS_URL`.
- **DELETE /cached**
- `curl -X 'DELETE' 'http://localhost:3636/cached?url=http://example.com/'`

# TODO
- [x] Render SPA page to get HTML
- [x] Cache HTML
- [x] Refresh cached HTML
- [x] Cache unlimited but controlled via API
- [x] Health status
- [x] Base environment
- [x] Docker image
- [x] Docker for local development
- [x] Domain limitation
- [x] Queue for rendering
- [ ] Accumulate Sitemap
- [ ] Different cache technology
- [ ] Different queue technology
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ services:
DEBUG: 1
PORT: 3636
REDIS_URL: redis://cache:6379/0
RABBITMQ_URL: amqp://queue:5672
depends_on:
- cache
- queue
ports:
- '3636:3636'
command: npm run start:dev
Expand All @@ -28,5 +30,14 @@ services:
volumes:
- cache:/data/cache

queue:
image: rabbitmq:management
restart: always
ports:
- '5672:5672'
- '15672:15672'
volumes:
- cache:/data/queue

volumes:
cache:
Loading

0 comments on commit f4852fc

Please sign in to comment.