🐋 Docker and Gitea Workflow
All checks were successful
Deploy application / deploy (push) Successful in 19s
All checks were successful
Deploy application / deploy (push) Successful in 19s
- Moved tsx to dependencies as node TS support is 💩
- Renamed start-once to run-once
- TODOs
This commit is contained in:
parent
2e73baf98b
commit
aaa85e99cb
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.cache
|
||||||
|
.idea
|
||||||
|
httpRequests
|
||||||
|
.env.*
|
||||||
|
*.sqlite
|
||||||
|
jest.config.ts
|
||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
*.md
|
34
.gitea/workflows/deploy.yml
Normal file
34
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: Deploy application
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: host
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Actual budget
|
||||||
|
ACTUAL_BUDGET_ID: ${{ secrets.ACTUAL_BUDGET_ID }}
|
||||||
|
ACTUAL_SYNC_ID: ${{ secrets.ACTUAL_SYNC_ID }}
|
||||||
|
ACTUAL_SERVER_URL: ${{ secrets.ACTUAL_SERVER_URL }}
|
||||||
|
ACTUAL_PASSWORD: ${{ secrets.ACTUAL_PASSWORD }}
|
||||||
|
ACTUAL_ACCOUNT_IDS: ${{ secrets.ACTUAL_ACCOUNT_IDS }}
|
||||||
|
ACTUAL_DATA_DIR: ${{ var.ACTUAL_DATA_DIR }}
|
||||||
|
# Bank
|
||||||
|
BANK_INITIAL_REFRESH_TOKEN: ${{ secrets.BANK_INITIAL_REFRESH_TOKEN }}
|
||||||
|
BANK_OAUTH_CLIENT_ID: ${{ secrets.BANK_OAUTH_CLIENT_ID }}
|
||||||
|
BANK_OAUTH_CLIENT_SECRET: ${{ secrets.BANK_OAUTH_CLIENT_SECRET }}
|
||||||
|
BANK_OAUTH_STATE: ${{ secrets.BANK_OAUTH_STATE }}
|
||||||
|
BANK_OAUTH_REDIRECT_URI: ${{ secrets.BANK_OAUTH_REDIRECT_URI }}
|
||||||
|
BANK_ACCOUNT_IDS: ${{ secrets.BANK_ACCOUNT_IDS }}
|
||||||
|
# Configuration
|
||||||
|
LOG_LEVEL: ${{ var.LOG_LEVEL }}
|
||||||
|
DB_FILENAME: ${{ var.DB_FILENAME }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Run docker-compose
|
||||||
|
run: docker compose up -d --build
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM node:22-slim
|
||||||
|
LABEL authors="Martin Berg Alstad"
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ENV PNPM_HOME="/pnpm"
|
||||||
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
RUN corepack enable
|
||||||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
|
||||||
|
|
||||||
|
CMD ["pnpm", "start-prod"]
|
@ -24,5 +24,5 @@ pnpm start
|
|||||||
Start the application without a CronJob, it will run once, then shutdown.
|
Start the application without a CronJob, it will run once, then shutdown.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm start-once
|
pnpm run-once
|
||||||
```
|
```
|
||||||
|
22
docker-compose.yml
Normal file
22
docker-compose.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
services:
|
||||||
|
# TODO Database in storage
|
||||||
|
server:
|
||||||
|
container_name: actual_budget_sparebank1
|
||||||
|
restart: no # TODO unless-stopped
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
environment:
|
||||||
|
- ACTUAL_BUDGET_ID
|
||||||
|
- ACTUAL_SYNC_ID
|
||||||
|
- ACTUAL_SERVER_URL
|
||||||
|
- ACTUAL_PASSWORD
|
||||||
|
- ACTUAL_ACCOUNT_IDS
|
||||||
|
- ACTUAL_DATA_DIR
|
||||||
|
- BANK_INITIAL_REFRESH_TOKEN
|
||||||
|
- BANK_OAUTH_CLIENT_ID
|
||||||
|
- BANK_OAUTH_CLIENT_SECRET
|
||||||
|
- BANK_OAUTH_STATE
|
||||||
|
- BANK_OAUTH_REDIRECT_URI
|
||||||
|
- BANK_ACCOUNT_IDS
|
||||||
|
- LOG_LEVEL
|
||||||
|
- DB_FILENAME
|
@ -6,7 +6,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
"start": "dotenvx run --env-file=.env.local -- node --import=tsx ./src/main.ts | pino-pretty",
|
"start": "dotenvx run --env-file=.env.local -- node --import=tsx ./src/main.ts | pino-pretty",
|
||||||
"start-once": "ONCE=true dotenvx run --env-file=.env.local -- node --import=tsx ./src/main.ts | pino-pretty",
|
"start-prod": "node --import=tsx ./src/main.ts",
|
||||||
|
"run-once": "ONCE=true dotenvx run --env-file=.env.local -- node --import=tsx ./src/main.ts | pino-pretty",
|
||||||
"test": "dotenvx run --env-file=.env.test.local -- node --experimental-vm-modules node_modules/jest/bin/jest.js | pino-pretty",
|
"test": "dotenvx run --env-file=.env.test.local -- node --experimental-vm-modules node_modules/jest/bin/jest.js | pino-pretty",
|
||||||
"format": "prettier --write \"./**/*.{js,mjs,ts,md,json}\""
|
"format": "prettier --write \"./**/*.{js,mjs,ts,md,json}\""
|
||||||
},
|
},
|
||||||
@ -21,7 +22,8 @@
|
|||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"pino": "^9.6.0",
|
"pino": "^9.6.0",
|
||||||
"prettier": "^3.4.2"
|
"prettier": "^3.4.2",
|
||||||
|
"tsx": "^4.19.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@jest/globals": "^29.7.0",
|
"@jest/globals": "^29.7.0",
|
||||||
@ -32,7 +34,6 @@
|
|||||||
"pino-pretty": "^13.0.0",
|
"pino-pretty": "^13.0.0",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsx": "^4.19.2",
|
|
||||||
"typescript": "^5.7.3"
|
"typescript": "^5.7.3"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
|
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@ -32,6 +32,9 @@ importers:
|
|||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.4.2
|
specifier: ^3.4.2
|
||||||
version: 3.4.2
|
version: 3.4.2
|
||||||
|
tsx:
|
||||||
|
specifier: ^4.19.2
|
||||||
|
version: 4.19.2
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@jest/globals':
|
'@jest/globals':
|
||||||
specifier: ^29.7.0
|
specifier: ^29.7.0
|
||||||
@ -57,9 +60,6 @@ importers:
|
|||||||
ts-node:
|
ts-node:
|
||||||
specifier: ^10.9.2
|
specifier: ^10.9.2
|
||||||
version: 10.9.2(@types/node@22.10.7)(typescript@5.7.3)
|
version: 10.9.2(@types/node@22.10.7)(typescript@5.7.3)
|
||||||
tsx:
|
|
||||||
specifier: ^4.19.2
|
|
||||||
version: 4.19.2
|
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.7.3
|
specifier: ^5.7.3
|
||||||
version: 5.7.3
|
version: 5.7.3
|
||||||
|
@ -19,6 +19,10 @@ import * as fs from "node:fs"
|
|||||||
import { CronJob } from "cron"
|
import { CronJob } from "cron"
|
||||||
|
|
||||||
// TODO Transports api for pino https://github.com/pinojs/pino/blob/HEAD/docs/transports.md
|
// TODO Transports api for pino https://github.com/pinojs/pino/blob/HEAD/docs/transports.md
|
||||||
|
// TODO create Dockerfile and docker-compose.yml
|
||||||
|
// TODO Gitea workflow
|
||||||
|
// TODO move tsx to devDependency. Requires ts support for Node with support for @ alias
|
||||||
|
// TODO global exception handler, log and graceful shutdown
|
||||||
|
|
||||||
export async function daily(actual: Actual, bank: Bank): Promise<void> {
|
export async function daily(actual: Actual, bank: Bank): Promise<void> {
|
||||||
// Fetch transactions from the bank
|
// Fetch transactions from the bank
|
||||||
|
Loading…
x
Reference in New Issue
Block a user