Skip to content

Commit 7172995

Browse files
authored
docs: add vite configuration to docker guide (medusajs#14352)
1 parent 0277062 commit 7172995

File tree

3 files changed

+190
-3
lines changed

3 files changed

+190
-3
lines changed

www/apps/book/app/learn/installation/docker/page.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ services:
9797
- redis
9898
ports:
9999
- "9000:9000"
100+
- "5173:5173"
100101
environment:
101102
- NODE_ENV=development
102103
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/medusa-store
@@ -139,6 +140,7 @@ If this isn't the first Medusa project you're setting up with Docker on your mac
139140
- Use `"5433:5432"` for PostgreSQL.
140141
- Use `"6380:6379"` for Redis.
141142
- Use `"9001:9000"` for the Medusa server.
143+
- Use `"5174:5173"` for the Medusa Admin dashboard.
142144
- Update the `DATABASE_URL` and `REDIS_URL` environment variables accordingly.
143145

144146
---
@@ -333,6 +335,8 @@ Where:
333335

334336
## 7. Update Medusa Configuration
335337

338+
### Disable SSL for PostgreSQL Connection
339+
336340
If you try to run the Medusa application now with Docker, you'll encounter an SSL error as the server tries to connect to the PostgreSQL database.
337341

338342
To resolve the error, add the following configurations in `medusa-config.ts`:
@@ -355,6 +359,43 @@ module.exports = defineConfig({
355359

356360
You add the [projectConfig.databaseDriverOptions](../../configurations/medusa-config/page.mdx#databasedriveroptions) to disable SSL for the PostgreSQL database connection.
357361

362+
### Add Vite Configuration for Medusa Admin
363+
364+
To ensure that the Medusa Admin dashboard works correctly when running inside Docker, connects to the Medusa server, and reloads properly with Hot Module Replacement (HMR), add the following Vite configuration in `medusa-config.ts`:
365+
366+
```ts title="medusa-config.ts"
367+
module.exports = defineConfig({
368+
// ...
369+
admin: {
370+
vite: (config) => {
371+
return {
372+
...config,
373+
server: {
374+
...config.server,
375+
host: "0.0.0.0",
376+
// Allow all hosts when running in Docker (development mode)
377+
// In production, this should be more restrictive
378+
allowedHosts: [
379+
"localhost",
380+
".localhost",
381+
"127.0.0.1",
382+
],
383+
hmr: {
384+
...config.server?.hmr,
385+
// HMR websocket port inside container
386+
port: 5173,
387+
// Port browser connects to (exposed in docker-compose.yml)
388+
clientPort: 5173,
389+
},
390+
},
391+
}
392+
},
393+
},
394+
})
395+
```
396+
397+
You configure the Vite development server to listen on all network interfaces (`0.0.0.0`) and set up HMR to work correctly within the Docker environment.
398+
358399
---
359400

360401
## 8. Add `.dockerignore`

www/apps/book/generated/edit-dates.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const generatedEditDates = {
123123
"app/learn/fundamentals/module-links/index/page.mdx": "2025-05-23T07:57:58.958Z",
124124
"app/learn/fundamentals/module-links/index-module/page.mdx": "2025-11-26T11:20:25.961Z",
125125
"app/learn/introduction/build-with-llms-ai/page.mdx": "2025-12-09T14:17:13.295Z",
126-
"app/learn/installation/docker/page.mdx": "2025-10-24T08:53:46.445Z",
126+
"app/learn/installation/docker/page.mdx": "2025-12-18T11:18:25.856Z",
127127
"app/learn/fundamentals/generated-types/page.mdx": "2025-07-25T13:17:35.319Z",
128128
"app/learn/introduction/from-v1-to-v2/page.mdx": "2025-10-29T11:55:11.531Z",
129129
"app/learn/debugging-and-testing/debug-workflows/page.mdx": "2025-07-30T13:45:14.117Z",

0 commit comments

Comments
 (0)