feat: Initial move to docker image
Build and publish / build (push) Failing after 2m37s

This commit is contained in:
Lino Silva
2026-04-10 17:24:44 +01:00
parent be8ff08f94
commit fe4c54ebcb
10 changed files with 3153 additions and 112 deletions
+87 -11
View File
@@ -1,21 +1,97 @@
# bpi-stock-price-scraper
Extrair preço de PPRs para introduzir no Ghostfolio
Web server API to fetch latest BPI PPR stock prices on demand.
# Utilização
## Features
Criar ficheiro `.env` a partir do `.env.example`
- REST API endpoints to get latest prices for BPI Destino PPR funds
- Returns price data as JSON
- Dockerized for easy deployment
- Health check endpoint included
## Docker
## Available Symbols
```
docker compose build
docker compose up
- `BPIDEST2040` - BPI Destino PPR 2040
- `BPIDEST2050` - BPI Destino PPR 2050
## API Endpoints
- `GET /` - API information and usage examples
- `GET /health` - Health check with available symbols
- `GET /price/:symbol` - Get latest price for a specific symbol
### Example Response
```json
{
"symbol": "BPIDEST2040",
"name": "BPI Destino PPR 2040",
"price": 7.73313,
"date": "2026-04-09",
"timestamp": "2026-04-10T16:11:25.850Z"
}
```
## Node
## Usage
### Docker (Recommended)
Build and run with docker-compose:
```bash
docker compose up -d
```
Or build and run manually:
```bash
docker build -t bpi-stock-price-scraper .
docker run -p 3000:3000 bpi-stock-price-scraper
```
### Node.js
Install dependencies and run:
```bash
npm install
npm start
```
For development with auto-reload:
```bash
npm run dev
```
## Configuration
The server runs on port 3000 by default. You can change it via the `PORT` environment variable:
```bash
PORT=8080 npm start
```
Or in docker-compose.yml:
```yaml
environment:
- PORT=8080
ports:
- "8080:8080"
```
## Testing
Test the API:
```bash
# Get API info
curl http://localhost:3000/
# Check health
curl http://localhost:3000/health
# Get latest price
curl http://localhost:3000/price/BPIDEST2040
```
yarn
node index.mjs
```