dev: add scripts to prepare dev environment

This commit is contained in:
naskya 2024-02-12 02:23:25 +09:00
parent ee803cd1f8
commit 567ae0efb5
No known key found for this signature in database
GPG Key ID: 712D413B3A9FED5C
7 changed files with 79 additions and 61 deletions

3
.gitignore vendored
View File

@ -29,9 +29,6 @@ coverage
!/.config/helm_values_example.yml
!/.config/LICENSE
# docker dev config
/dev/docker-compose.yml
# ESLint
.eslintcache

View File

@ -69,6 +69,42 @@ Be willing to comment on the good points and not just the things you want fixed
- Are there any omissions or gaps?
- Does it check for anomalies?
## Preparing the development environment
1. Install the following software
- nodejs
- rustup
- cargo
- sea-orm-cli
- podman
- podman-compose
1. Copy the config file
```sh
cp .config/dev.example.yml .config/default.yml
```
1. Start postgres/redis containers
```sh
pnpm run dev:up
```
1. Build Firefish
```sh
pnpm install
pnpm run build:debug
pnpm run migrate
```
1. Start Firefish on your localhost
```sh
pnpm run start
```
You can use the following commands to initialize the database:
```sh
pnpm run dev:init
pnpm run migrate
```
Make sure to clear your browser local storage after initializing the dev instance.
## Deploy (SOON)
The `/deploy` command by issue comment can be used to deploy the contents of a MR to the preview environment.
```

15
dev/docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
version: "3"
services:
redis:
image: docker.io/redis:7-alpine
ports:
- "26379:6379"
db:
image: docker.io/postgres:16-alpine
environment:
- "POSTGRES_PASSWORD=password"
- "POSTGRES_USER=firefish"
- "POSTGRES_DB=firefish_db"
ports:
- "25432:5432"

View File

@ -1,57 +0,0 @@
version: "3"
services:
web:
image: registry.firefish.dev/firefish/firefish
build: ..
container_name: firefish_web
restart: always
depends_on:
- db
- redis
# - es
ports:
- "3000:3000"
networks:
- network
# - web
volumes:
- ../files:/firefish/files
- ../.config:/firefish/.config:ro
redis:
restart: always
container_name: firefish_redis
image: docker.io/redis:7.0-alpine
networks:
- network
volumes:
- ../redis:/data
db:
restart: always
image: docker.io/postgres:12.2-alpine
container_name: firefish_db
networks:
- network
env_file:
- ../.config/docker.env
volumes:
- ../db:/var/lib/postgresql/data
# es:
# restart: always
# image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.2
# environment:
# - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
# - "TAKE_FILE_OWNERSHIP=111"
# networks:
# - network
# volumes:
# - ./elasticsearch:/usr/share/elasticsearch/data
networks:
network:
# web:
# external:
# name: web

View File

@ -19,9 +19,12 @@
"gulp": "gulp build",
"watch": "pnpm run dev",
"dev": "pnpm node ./scripts/dev.mjs",
"dev:up": "pnpm node ./scripts/dev-up.mjs",
"dev:down": "pnpm node ./scripts/dev-down.mjs",
"dev:init": "pnpm run dev:down && pnpm run dev:up",
"dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start",
"lint": "pnpm -r --parallel run lint",
"debug": "pnpm run build:debug && pnpm run start",
"debug": "pnpm run clean && pnpm run build:debug && pnpm run start",
"build:debug": "pnpm -r --parallel run build:debug && pnpm run gulp",
"cy:open": "cypress open --browser --e2e --config-file=cypress.config.ts",
"cy:run": "cypress run",

12
scripts/dev-down.mjs Normal file
View File

@ -0,0 +1,12 @@
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"),
stdio: "inherit",
});
})();

12
scripts/dev-up.mjs Normal file
View File

@ -0,0 +1,12 @@
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"),
stdio: "inherit",
});
})();