dev: port some scripts in package.json to Makefile
This commit is contained in:
parent
76c1caa523
commit
996610aa2e
14 changed files with 57 additions and 78 deletions
.gitignoreMakefile
dev
package.jsonpackages/backend-rs
scripts
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -63,6 +63,7 @@ packages/megalodon/.idea
|
|||
dev/container/firefish
|
||||
dev/container/db
|
||||
dev/container/redis
|
||||
dev/config.env
|
||||
|
||||
# blender backups
|
||||
*.blend1
|
||||
|
|
18
Makefile
Normal file
18
Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
ifneq (dev,$(wildcard config.env))
|
||||
include ./dev/config.env
|
||||
export
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: db.init db.up db.down
|
||||
db.init:
|
||||
$(MAKE) -C ./dev/db-container init
|
||||
db.up:
|
||||
$(MAKE) -C ./dev/db-container up
|
||||
db.down:
|
||||
$(MAKE) -C ./dev/db-container down
|
||||
|
||||
.PHONY: entities
|
||||
entities:
|
||||
pnpm run migrate
|
||||
$(MAKE) -C ./packages/backend-rs regenerate-entities
|
4
dev/config.example.env
Normal file
4
dev/config.example.env
Normal file
|
@ -0,0 +1,4 @@
|
|||
COMPOSE='docker compose'
|
||||
POSTGRES_PASSWORD=password
|
||||
POSTGRES_USER=firefish
|
||||
POSTGRES_DB=firefish_db
|
|
@ -38,10 +38,8 @@ services:
|
|||
container_name: firefish_db
|
||||
networks:
|
||||
- firefishnet
|
||||
environment:
|
||||
- "POSTGRES_PASSWORD=password"
|
||||
- "POSTGRES_USER=firefish"
|
||||
- "POSTGRES_DB=firefish_db"
|
||||
env_file:
|
||||
- ../config.env
|
||||
ports:
|
||||
- "25432:5432"
|
||||
volumes:
|
||||
|
|
6
dev/db-container/Makefile
Normal file
6
dev/db-container/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
.PHONY: init up down
|
||||
init: down up
|
||||
up:
|
||||
$(COMPOSE) up --detach
|
||||
down:
|
||||
$(COMPOSE) down
|
|
@ -7,10 +7,8 @@ services:
|
|||
- "26379:6379"
|
||||
db:
|
||||
image: docker.io/groonga/pgroonga:3.1.8-alpine-12
|
||||
environment:
|
||||
- "POSTGRES_PASSWORD=password"
|
||||
- "POSTGRES_USER=firefish"
|
||||
- "POSTGRES_DB=firefish_db"
|
||||
env_file:
|
||||
- ../config.env
|
||||
ports:
|
||||
- "25432:5432"
|
||||
volumes:
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
1. Download the [`dev/container` directory](./dev/container) and execute `chmod +x docker-entrypoint.sh`
|
||||
- Alternatively, you can use `git clone https://firefish.dev/firefish/firefish.git && cd firefish/dev/container`, although this will clone the entire repository.
|
||||
1. Copy the example config file
|
||||
```sh
|
||||
cp config.example.env config.env
|
||||
```
|
||||
1. Edit `docker-compose.yml` and set `URL` to the URL you want to use (or leave it as `http://localhost:3030`)
|
||||
1. Run `docker compose up`
|
||||
- This will build the environment, install dependencies and prepare the needed config files.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
- [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose)
|
||||
- [containerd](https://github.com/containerd/containerd) and [nerdctl](https://github.com/containerd/nerdctl)
|
||||
- or whatever you want to use
|
||||
- GNU Make
|
||||
- The following ports are not in use
|
||||
- 25432
|
||||
- 26379
|
||||
|
@ -27,6 +28,12 @@ You can refer to [local-installation.md](./local-installation.md) to install the
|
|||
git clone https://firefish.dev/your-user-name/firefish.git
|
||||
cd firefish
|
||||
```
|
||||
1. Copy example config file
|
||||
```sh
|
||||
cp dev/config.example.env dev/config.env
|
||||
# If you use container runtime other than Docker, you need to modify the "COMPOSE" variable
|
||||
# vim dev/config.env
|
||||
```
|
||||
1. Create `.config/default.yml` with the following content
|
||||
```yaml
|
||||
# You can change the port if 3000 is already used
|
||||
|
@ -53,13 +60,7 @@ You can refer to [local-installation.md](./local-installation.md) to install the
|
|||
```
|
||||
1. Start database containers
|
||||
```sh
|
||||
cd dev/db-container
|
||||
docker compose up --detach
|
||||
# or podman-compose up --detach
|
||||
# or whatever
|
||||
|
||||
# go back to the repository root
|
||||
cd ../..
|
||||
make db.up
|
||||
```
|
||||
|
||||
## Build and start Firefish
|
||||
|
@ -88,11 +89,7 @@ You can refer to [local-installation.md](./local-installation.md) to install the
|
|||
You can recreate a fresh local Firefish environment by recreating the database containers:
|
||||
|
||||
```sh
|
||||
cd dev/db-container
|
||||
docker compose down
|
||||
docker compose up --detach
|
||||
cd ../..
|
||||
|
||||
make db.init
|
||||
pnpm run migrate
|
||||
pnpm run start
|
||||
```
|
||||
|
|
|
@ -114,7 +114,11 @@ sudo apt install ffmpeg
|
|||
```sh
|
||||
git clone https://firefish.dev/your-user-name/firefish.git
|
||||
```
|
||||
1. Create the config file
|
||||
1. Copy the example database config file
|
||||
```sh
|
||||
cp dev/config.example.env dev/config.env
|
||||
```
|
||||
1. Create a config file for Firefish
|
||||
```sh
|
||||
cd firefish
|
||||
vim .config/default.yml
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
"watch": "pnpm run dev",
|
||||
"dev": "pnpm node ./scripts/dev.mjs",
|
||||
"dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start",
|
||||
"db:up": "pnpm node ./scripts/db-up.mjs",
|
||||
"db:down": "pnpm node ./scripts/db-down.mjs",
|
||||
"db:init": "pnpm run dev:down && pnpm run dev:up",
|
||||
"lint": "pnpm -r --parallel run lint",
|
||||
"debug": "pnpm run build:debug && pnpm run start",
|
||||
"build:debug": "pnpm run clean && pnpm node ./scripts/dev-build.mjs && pnpm run gulp",
|
||||
|
@ -32,8 +29,7 @@
|
|||
"clean": "pnpm node ./scripts/clean-built.mjs",
|
||||
"clean-npm": "pnpm node ./scripts/clean-npm.mjs",
|
||||
"clean-cargo": "pnpm node ./scripts/clean-cargo.mjs",
|
||||
"clean-all": "pnpm run clean && pnpm run clean-cargo && pnpm run clean-npm",
|
||||
"entities": "pnpm node ./scripts/regenerate-sea-orm-entities.mjs"
|
||||
"clean-all": "pnpm run clean && pnpm run clean-cargo && pnpm run clean-npm"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "4.1.0",
|
||||
|
|
5
packages/backend-rs/Makefile
Normal file
5
packages/backend-rs/Makefile
Normal file
|
@ -0,0 +1,5 @@
|
|||
.PHONY: regenerate-entities
|
||||
regenerate-entities:
|
||||
sea-orm-cli generate entity \
|
||||
--output-dir='src/model/entity' \
|
||||
--database-url='postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@localhost:25432/$(POSTGRES_DB)'
|
|
@ -1,12 +0,0 @@
|
|||
import path, { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { execa } from "execa";
|
||||
|
||||
(async () => {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
execa("podman-compose", ["down"], {
|
||||
cwd: join(__dirname, "/../dev/db-container"),
|
||||
stdio: "inherit",
|
||||
});
|
||||
})();
|
|
@ -1,12 +0,0 @@
|
|||
import path, { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { execa } from "execa";
|
||||
|
||||
(async () => {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
execa("podman-compose", ["up", "--detach"], {
|
||||
cwd: join(__dirname, "/../dev/db-container"),
|
||||
stdio: "inherit",
|
||||
});
|
||||
})();
|
|
@ -1,28 +0,0 @@
|
|||
import path, { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { execa } from "execa";
|
||||
|
||||
(async () => {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// from dev/docker-compose.yml
|
||||
const POSTGRES_USER = "firefish";
|
||||
const POSTGRES_PASSWORD = "password";
|
||||
const POSTGRES_DB = "firefish_db";
|
||||
const POSTGRES_PORT = "25432";
|
||||
|
||||
await execa("pnpm", ["run", "migrate"], {
|
||||
cwd: join(__dirname, "/.."),
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
await execa("sea-orm-cli", [
|
||||
"generate",
|
||||
"entity",
|
||||
"--output-dir=src/model/entity",
|
||||
`--database-url=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${POSTGRES_PORT}/${POSTGRES_DB}`,
|
||||
], {
|
||||
cwd: join(__dirname, "/../packages/backend-rs"),
|
||||
stdio: "inherit",
|
||||
});
|
||||
})();
|
Loading…
Add table
Reference in a new issue