Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ db/

# Dist folders
dist-static
dist-server
dist-server

# Docker Compose environment file
.env.docker
8 changes: 8 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM oven/bun:1.3-alpine

WORKDIR /app

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

COPY . .
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ Configure your Infisical project or create a `.env` file with required variables
bun dev
```

This command starts:
- PostgreSQL database (via Docker)
- Vite dev server with HMR
- Drizzle Studio for database management
This command starts the following services:
- **PostgreSQL**: Database service on port `5432`.
- **Migrator**: Automatically runs pending migrations.
- **Vite**: Development server with Hot Module Replacement at [localhost:5173](http://localhost:5173/).
- **Drizzle Studio**: Database GUI at [local.drizzle.studio](https://local.drizzle.studio)

The Vite server and Drizzle Studio run inside Docker containers. To ensure the stack remains fast, a custom development image is used. We bind the current directory to a Docker volume, so code changes are immediately reflected in the container.

**Note on dependencies**: Since `node_modules` are cached, you must rebuild the containers if you add or change packages. You can do this by running:

```bash
bun dev --build
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The command bun dev --build is not the correct way to pass arguments to a bun script; this passes the --build flag to bun itself, not the script. To pass arguments to the script, you should use bun dev -- --build. Please update the documentation to reflect the correct command usage.

Suggested change
bun dev --build
bun dev -- --build

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works in bun.

```

## Scripts

Expand Down
17 changes: 0 additions & 17 deletions bun.lock

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

52 changes: 52 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,55 @@ services:
interval: 10s
timeout: 5s
retries: 5

# One-time task to run migrations
migrator:
build:
context: .
dockerfile: Dockerfile.dev
command: bun drizzle-kit migrate
depends_on:
postgres:
condition: service_healthy
env_file: .env.docker
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-postgres}
Comment on lines +21 to +31
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a ideja je, da maš prazno bazo k je prpravlena, če pa hočš staging bazo jo pa separately itak popolnoma povozš (torej ni nekih konfliktov?)


vite:
build:
context: .
dockerfile: Dockerfile.dev
env_file: .env.docker
environment:
- WATCHPACK_POLLING=true
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-postgres}
command: bun run dev:app --host=0.0.0.0
ports:
- "5173:5173"
volumes:
- .:/app # Edits on host are reflected in container
- /app/node_modules
depends_on:
postgres:
condition: service_healthy
migrator:
condition: service_completed_successfully

studio:
build:
context: .
dockerfile: Dockerfile.dev
env_file: .env.docker
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-postgres}
command: bun run db:studio --port 4983 --host 0.0.0.0
ports:
- "4983:4983"
volumes:
- .:/app # Edits on host are reflected in container
- /app/node_modules
depends_on:
postgres:
condition: service_healthy
migrator:
condition: service_completed_successfully
Comment on lines +20 to +70
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The definitions for migrator, vite, and studio services share a lot of common configuration, such as build, env_file, and environment. This repetition can make the file harder to maintain. Consider using YAML anchors and aliases to reduce duplication. For example, you could define a common build block and reuse it:

x-common-build: &common-build
  build:
    context: .
    dockerfile: Dockerfile.dev

services:
  migrator:
    <<: *common-build
    # ... rest of migrator config
  vite:
    <<: *common-build
    # ... rest of vite config

You can apply a similar pattern for other repeated sections like environment or volumes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literally no one can read this. I think we can leave as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean, arent we all yaml fans and experts

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"type": "module",
"private": true,
"scripts": {
"dev": "infisical run -- bun -b concurrently --names \"DOCKER,APP\" -c \"blue,magenta\" \"bun run db:start\" \"bun run db:wait && bun run dev:app\"",
"dev:app": "concurrently --names \"VITE,STUDIO\" -c \"cyan,yellow\" \"vite dev\" \"bun run db:studio\"",
"dev": "infisical export --format=dotenv > .env.docker && docker compose -f docker-compose.dev.yml up",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The dev script doesn't forward arguments to docker compose up. This means bun dev --build (as mentioned in README.md) won't work as expected because the --build flag isn't passed to Docker Compose. To fix this, you can wrap the command in sh -c to correctly handle and forward any arguments.

Suggested change
"dev": "infisical export --format=dotenv > .env.docker && docker compose -f docker-compose.dev.yml up",
"dev": "sh -c 'infisical export --format=dotenv > .env.docker && docker compose -f docker-compose.dev.yml up \"$@\"' --",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works in bun.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow okay bun is smart

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a normal infisical run does not work? damn

"dev:app": "vite dev",
"db:studio": "drizzle-kit studio",
"db:start": "docker compose -f docker-compose.dev.yml up",
"db:wait": "bash -c 'until docker compose -f docker-compose.dev.yml exec -T postgres pg_isready -U ${POSTGRES_USER:-postgres} > /dev/null 2>&1; do sleep 1; done'",
Expand Down Expand Up @@ -36,7 +36,6 @@
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.2",
"concurrently": "^9.0.0",
"react-router-dom": "^6.26.2",
"tw-animate-css": "^1.4.0",
"vite": "^7.3.0",
Expand Down Expand Up @@ -90,4 +89,4 @@
"tailwindcss": "^4.1.18",
"zod": "^4.3.5"
}
}
}
108 changes: 0 additions & 108 deletions scripts/dev.ts

This file was deleted.