Skip to content

Commit 25f839d

Browse files
committed
fix(docker): fix Dockerfile build issues and static file serving
- Update npm command from deprecated --only=production to --omit=dev - Configure vite build output to dist/client directory - Fix static file path resolution in server to support both tsx and compiled execution modes
1 parent b2b8d88 commit 25f839d

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ WORKDIR /app
4848

4949
# Install production dependencies only
5050
COPY package*.json ./
51-
RUN npm ci --only=production && npm cache clean --force
51+
RUN npm ci --omit=dev && npm cache clean --force
5252

5353
# Install tsx globally for running TypeScript
5454
RUN npm install -g tsx

src/server/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ app.get('/api/health', (req, res) => {
3232
});
3333

3434
// Serve static files from React app (in production)
35-
const clientDistPath = path.join(__dirname, '../../client');
35+
// Handle both cases:
36+
// 1. When running with tsx from src/server/index.ts: __dirname = /app/src/server, need ../../dist/client
37+
// 2. When running compiled dist/index.js: __dirname = /app/dist, need ./client
38+
let clientDistPath = path.join(__dirname, './client');
39+
if (!existsSync(clientDistPath)) {
40+
// Try alternative path for tsx execution
41+
clientDistPath = path.join(__dirname, '../../dist/client');
42+
}
3643

3744
// Check if client dist exists (for production builds)
3845
if (existsSync(clientDistPath)) {

vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import path from 'path'
44

55
export default defineConfig({
66
plugins: [react()],
7+
build: {
8+
outDir: 'dist/client',
9+
},
710
resolve: {
811
alias: {
912
'@': path.resolve(__dirname, './src'),

0 commit comments

Comments
 (0)