Skip to content

Commit 0bf3213

Browse files
authored
docs: 📝 update docs and .env.example to work with docker compose out of the box (#7)
1 parent bc27202 commit 0bf3213

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SERVER_PORT=3000
1010

1111
# Database Configuration
1212
# Replace with your actual PostgreSQL connection details
13-
DATABASE_URL=postgresql://username:password@localhost:5432/elysia-boilerplate
13+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/elysia-boilerplate
1414

1515
# Enable migrations on server startup
1616
DB_AUTO_MIGRATE=false

README.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,40 @@ A modern, production-ready boilerplate for building APIs with Elysia, Bun runtim
2525
## Prerequisites
2626

2727
- [Bun](https://bun.sh) (latest version)
28-
- [PostgreSQL](https://www.postgresql.org) (12+)
2928

3029
## Installation
3130

3231
1. **Clone the repository**
32+
3333
```bash
3434
git clone <repository-url>
3535
cd elysia-boilerplate
3636
```
3737

3838
2. **Install dependencies**
39+
3940
```bash
4041
bun install
4142
```
4243

4344
3. **Set up PostgreSQL**
44-
- Install and start PostgreSQL on your system
45-
- Create a database for your project
46-
- Note the connection details (host, port, database name, username, password)
45+
46+
**Recommended approach**: The easiest way to get started is to use the provided Docker Compose setup, which will start PostgreSQL instantly:
47+
48+
```bash
49+
docker-compose up -d elysia-boilerplate-postgres
50+
```
51+
52+
**Alternative**: If you prefer to run your own PostgreSQL instance, create a database for your project and note the connection details (host, port, database name, username, password). **Remember to update your `.env` file** with the correct `DATABASE_URL` connection string.
4753

4854
4. **Create and configure environment variables**
55+
4956
```bash
5057
cp .env.example .env
5158
```
52-
59+
5360
**Important**: You must create a `.env` file from the provided `.env.example` template and update it with your PostgreSQL connection details:
61+
5462
```env
5563
NODE_ENV=development
5664
LOG_LEVEL=info
@@ -60,13 +68,15 @@ A modern, production-ready boilerplate for building APIs with Elysia, Bun runtim
6068
```
6169

6270
5. **Run database migrations**
71+
6372
```bash
6473
bun run db:migrate
6574
```
6675

6776
## Development
6877

6978
Start the development server with hot reload:
79+
7080
```bash
7181
bun run dev
7282
```
@@ -94,11 +104,13 @@ This project includes a testing setup using Bun's built-in test runner. Tests ar
94104
### Running Tests
95105

96106
To run all tests:
107+
97108
```bash
98109
bun test
99110
```
100111

101112
To run tests with coverage:
113+
102114
```bash
103115
bun test --coverage
104116
```
@@ -108,16 +120,17 @@ bun test --coverage
108120
Add your test files to the `src/tests/` folder. Test files should follow the naming convention `*.test.ts`.
109121

110122
Example test structure:
111-
```
123+
124+
```text
112125
src/tests/
113-
├── users.test.ts # User module tests
114-
├── auth.test.ts # Authentication tests
115-
└── api.test.ts # API endpoint tests
126+
├── users.test.ts # User module tests
127+
├── auth.test.ts # Authentication tests
128+
└── api.test.ts # API endpoint tests
116129
```
117130

118131
## Project Structure
119132

120-
```
133+
```text
121134
src/
122135
├── db/ # Database configuration and schema
123136
│ ├── migrations/ # Database migrations
@@ -160,27 +173,31 @@ The application uses [Envalid](https://github.com/af/envalid) for type-safe envi
160173
| `LOG_LEVEL` | string | `info` | Logging level |
161174
| `SERVER_HOSTNAME` | string | `localhost` | Server hostname |
162175
| `SERVER_PORT` | number | `3000` | Server port |
163-
| `DATABASE_URL` | string | - | PostgreSQL connection URL |
176+
| `DATABASE_URL` | string | `postgresql://postgres:postgres@localhost:5432/elysia-boilerplate` | PostgreSQL connection URL |
164177

165178
## API Documentation
166179

167180
Once the server is running, you can access the interactive API documentation at:
181+
168182
- **Scala UI**: `http://localhost:3000/openapi`
169183
- **OpenAPI JSON**: `http://localhost:3000/openapi/json`
170184

171185
## Database Management
172186

173187
### Generate a new migration
188+
174189
```bash
175190
bun run db:generate
176191
```
177192

178193
### Apply migrations
194+
179195
```bash
180196
bun run db:migrate
181197
```
182198

183199
### Open Drizzle Studio
200+
184201
```bash
185202
bun run db:studio
186203
```
@@ -205,33 +222,11 @@ docker-compose down
205222
```
206223

207224
This will start:
225+
208226
- **Elysia application** on `http://localhost:3000`
209227
- **PostgreSQL database** on `localhost:5432`
210228
- **Automatic database migrations** on startup
211229

212-
### Manual Docker Build
213-
214-
If you prefer to build and run manually:
215-
216-
```bash
217-
# Build the Docker image
218-
docker build -t elysia-boilerplate .
219-
220-
# Run PostgreSQL
221-
docker run -d --name postgres \
222-
-e POSTGRES_USER=postgres \
223-
-e POSTGRES_PASSWORD=postgres \
224-
-e POSTGRES_DB=elysia-boilerplate \
225-
-p 5432:5432 \
226-
postgres:17-alpine
227-
228-
# Run the application
229-
docker run -d --name elysia-app \
230-
-p 3000:3000 \
231-
-e DATABASE_URL=postgresql://postgres:[email protected]:5432/elysia-boilerplate \
232-
elysia-boilerplate
233-
```
234-
235230
### Docker Configuration
236231

237232
- **Dockerfile**: Multi-stage build using Bun runtime, compiles TypeScript and creates optimized binary
@@ -241,18 +236,21 @@ docker run -d --name elysia-app \
241236
## Production Deployment
242237

243238
1. **Build the application**
239+
244240
```bash
245241
bun run build
246242
```
247243

248244
2. **Set production environment variables**
245+
249246
```bash
250247
export NODE_ENV=production
251248
export DATABASE_URL=your_production_database_url
252249
# ... other production variables
253250
```
254251

255252
3. **Run the application**
253+
256254
```bash
257255
./build/server
258256
```

0 commit comments

Comments
 (0)