Skip to content

Commit

Permalink
Chore: Docker compose plugins dev (ToolJet#1953)
Browse files Browse the repository at this point in the history
* add plugins to docker compose

* build common

* change cmd

* build:pkgs

* fix'

* temp: add named vol

* update docker-compose for plugins dev

* update seed script to transpile only

* fix ci

* fix ci

Co-authored-by: gandharv <gandharvkumargarg@gmail.com>
  • Loading branch information
akshaysasidrn and gondar00 authored Jan 27, 2022
1 parent 96457e7 commit e3317aa
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 91 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ jobs:
${{ runner.os }}-
- run: apt update && apt install -y postgresql
- run: npm i -g npm@7.20.0
- run: npm --prefix plugins ci && npm --prefix plugins run build:packages && npm --prefix plugins run build:server
- run: npm --prefix plugins ci
- run: npm --prefix plugins run create:client && npm --prefix plugins run create:server
- run: npm --prefix plugins run build:packages && npm --prefix plugins run build:server
- run: npm --prefix server ci
- run: npm --prefix server run db:create
- run: npm --prefix server run db:migrate
Expand Down Expand Up @@ -160,7 +162,9 @@ jobs:
${{ runner.os }}-
- run: apt update && apt install -y postgresql
- run: npm i -g npm@7.20.0
- run: npm --prefix plugins ci && npm --prefix plugins run build:packages && npm --prefix plugins run build:server
- run: npm --prefix plugins ci
- run: npm --prefix plugins run create:client && npm --prefix plugins run create:server
- run: npm --prefix plugins run build:packages && npm --prefix plugins run build:server
- run: npm --prefix server ci
- run: npm --prefix server run db:create
- run: npm --prefix server run db:migrate
Expand Down
27 changes: 19 additions & 8 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
version: "3"

services:
plugins:
build:
context: ./
dockerfile: ./docker/plugins.Dockerfile.dev
image: tooljet-plugins:development
platform: linux/x86_64
volumes:
- plugins_vol:/app/plugins
command: npm run --prefix plugins start

client:
build:
context: ./
Expand All @@ -9,9 +19,7 @@ services:
platform: linux/x86_64
volumes:
- ./frontend:/app/frontend:delegated
- ./plugins/:/app/plugins
- /app/plugins/dist/
- /app/plugins/node_modules/
- plugins_vol:/app/plugins
- /app/frontend/node_modules/
ports:
- 8082:8082
Expand All @@ -30,12 +38,10 @@ services:
- postgres
volumes:
- ./server:/app/server:delegated
- ./plugins/:/app/plugins
- /app/plugins/dist/
- /app/plugins/node_modules/
- plugins_vol:/app/plugins
- /app/server/node_modules/
- ".env:/app/.env"
- ".env.test:/app/.env.test"
- ./.env:/app/.env
- ./.env.test:/app/.env.test
ports:
- 3000:3000
environment:
Expand All @@ -55,3 +61,8 @@ services:

volumes:
postgres:
plugins_vol:
driver_opts:
type: none
device: ${PWD}/plugins
o: bind
6 changes: 0 additions & 6 deletions docker/client.Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ ENV PATH /app/node_modules/.bin:$PATH
# Fix for heap limit allocation issue
ENV NODE_OPTIONS="--max-old-space-size=4096"

# Build plugins
COPY ./plugins/package.json ./plugins/package-lock.json ./plugins/
RUN npm --prefix plugins install
COPY ./plugins/ ./plugins/
RUN npm run build:plugins

# install app dependencies
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
RUN npm --prefix frontend install
Expand Down
17 changes: 17 additions & 0 deletions docker/plugins.Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# pull official base image
FROM node:14.17.3-alpine AS builder

RUN npm i -g npm@7.20.0

# set working directory
WORKDIR /app

COPY ./package.json ./package.json

# Fix for heap limit allocation issue
ENV NODE_OPTIONS="--max-old-space-size=4096"

# Build plugins
COPY ./plugins/package.json ./plugins/package-lock.json ./plugins/
RUN npm --prefix plugins install
COPY ./plugins/ ./plugins/
6 changes: 0 additions & 6 deletions docker/server.Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ WORKDIR /app

COPY ./package.json ./package.json

# Build plugins
COPY ./plugins/package.json ./plugins/package-lock.json ./plugins/
RUN npm --prefix plugins install
COPY ./plugins/ ./plugins/
RUN npm run build:plugins

# install app dependencies
COPY ./server/package.json ./server/package-lock.json ./server/
RUN npm --prefix server install
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/contributing-guide/setup/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ docker-compose version 1.26.2, build eefe0d31

```bash
docker-compose build
docker-compose run --rm plugins npm run build:plugins
```

5. Run ToolJet
Expand All @@ -91,7 +92,7 @@ docker-compose version 1.26.2, build eefe0d31
6. ToolJet server is built using NestJS and the data such as application definitions are persisted on a postgres database. You can run the below command to seed the database.

```bash
docker-compose run --rm server npm run db:seed
docker-compose exec server npm run db:seed
```

7. ToolJet should now be served locally at `http://localhost:8082`. You can login using the default user created.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"scripts": {
"prebuild:plugins": "npm --prefix plugins install",
"build:plugins": "npm --prefix plugins run build:packages && npm --prefix plugins run build:server",
"build:plugins": "npm --prefix plugins run build",
"prebuild:frontend": "npm --prefix frontend install",
"build:frontend": "NODE_ENV=production npm --prefix frontend run build",
"prebuild:server": "npm --prefix server install",
Expand Down
14 changes: 2 additions & 12 deletions plugins/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"types": "dist/server.d.ts",
"main": "dist/server.js",
"scripts": {
"clean": "rimraf dist/",
"create:client": "node create-client-entry",
"create:server": "node create-server-entry",
"prebuild:server": "npm run clean",
"build:server": "tsc -b",
"prebuild:packages": "npm run clean:packages && npm run create:client && npm run create:server",
"build:server": "rimraf dist/ && tsc -b",
"start": "tsc -b --watch",
"build": "npm run create:client && npm run create:server && npm run build:packages && npm run build:server",
"prebuild:packages": "npm run clean:packages",
"build:packages": "npx lerna run build --stream",
"clean:packages": "npx lerna run clean --parallel"
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"composite": true,
"resolveJsonModule": true
},
"exclude": ["packages/*/lib/*.json", "packages/*/__tests__/*"]
"exclude": ["packages/*/lib/*.json", "packages/*/__tests__/*", "dist"]
}
109 changes: 63 additions & 46 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"test:e2e": "NODE_ENV=test jest --runInBand --config ./test/jest-e2e.json --detectOpenHandles",
"db:create": "ts-node ./scripts/create-database.ts",
"db:drop": "ts-node ./scripts/drop-database.ts",
"db:migrate": "npm run typeorm migration:run",
"db:seed": "ts-node -r tsconfig-paths/register ./scripts/seeds.ts",
"db:migrate": "ts-node -r tsconfig-paths/register --transpile-only ./node_modules/typeorm/cli.js migration:run",
"db:seed": "ts-node -r tsconfig-paths/register --transpile-only ./scripts/seeds.ts",
"db:reset": "npm run db:drop && npm run db:create && npm run db:migrate",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ormconfig.ts"
},
Expand Down
Loading

0 comments on commit e3317aa

Please sign in to comment.