diff --git a/.gitignore b/.gitignore index 3c55ec0d78..9c372235e7 100644 --- a/.gitignore +++ b/.gitignore @@ -29,9 +29,6 @@ coverage !/.config/helm_values_example.yml !/.config/LICENSE -# docker dev config -/dev/docker-compose.yml - # ESLint .eslintcache diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 743eaef005..dec6f86a70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. ``` diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml new file mode 100644 index 0000000000..184c0366c9 --- /dev/null +++ b/dev/docker-compose.yml @@ -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" diff --git a/dev/docker-compose.yml.example b/dev/docker-compose.yml.example deleted file mode 100644 index e8f4dcbe52..0000000000 --- a/dev/docker-compose.yml.example +++ /dev/null @@ -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 diff --git a/package.json b/package.json index 855eba3631..2711ffa903 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/dev-down.mjs b/scripts/dev-down.mjs new file mode 100644 index 0000000000..97d9cd3515 --- /dev/null +++ b/scripts/dev-down.mjs @@ -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", + }); +})(); diff --git a/scripts/dev-up.mjs b/scripts/dev-up.mjs new file mode 100644 index 0000000000..c2de8717a3 --- /dev/null +++ b/scripts/dev-up.mjs @@ -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", + }); +})();