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
40 changes: 40 additions & 0 deletions apps/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM oven/bun:1.1.8-alpine AS base

WORKDIR /app

# Copy package files
COPY package.json bun.lockb ./
COPY apps/server/package.json ./apps/server/
COPY packages/ ./packages/

# Install dependencies
RUN bun install --frozen-lockfile

# Copy source code
COPY apps/server/ ./apps/server/
COPY turbo.json ./

# Build the application
RUN bun run build

# Production stage
FROM oven/bun:1.1.8-alpine AS production

WORKDIR /app

# Copy built application
COPY --from=base /app/apps/server/dist ./dist
COPY --from=base /app/node_modules ./node_modules
COPY --from=base /app/apps/server/package.json ./

# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S bun -u 1001
USER bun

EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1

CMD ["bun", "run", "dist/index.js"]
38 changes: 38 additions & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM oven/bun:1.1.8-alpine AS base

WORKDIR /app

# Copy package files
COPY package.json bun.lockb ./
COPY apps/web/package.json ./apps/web/
COPY packages/ ./packages/

# Install dependencies
RUN bun install --frozen-lockfile

# Copy source code
COPY apps/web/ ./apps/web/
COPY turbo.json ./

# Build the application
RUN bun run build

# Production stage
FROM nginx:alpine AS production

# Copy built application
COPY --from=base /app/apps/web/dist /usr/share/nginx/html

# Copy custom nginx config
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf

# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nginx -u 1001

EXPOSE 3001

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3001 || exit 1

CMD ["nginx", "-g", "daemon off;"]
42 changes: 42 additions & 0 deletions apps/web/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
server {
listen 3001;
server_name _;
root /usr/share/nginx/html;
index index.html;

# Security headers
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/xml+rss
application/json;

# Handle client-side routing
location / {
try_files $uri $uri/ /index.html;
}

# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}

# Health check
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
19 changes: 16 additions & 3 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@ export default defineConfig({
react(),
tanstackRouter({}),
],
build: {
minify: 'esbuild', // lightweight minifier
sourcemap: false,
chunkSizeWarningLimit: 10000, // avoid large chunk warnings
rollupOptions: {
output: {
// Only manually chunk large external dependencies
manualChunks(id) {
if (id.includes('node_modules/starknetkit')) return 'starknetkit';
},
},
},
},
optimizeDeps: {
include: ['@dynamic-labs/sdk-react-core']
exclude: ['@dynamic-labs/sdk-react-core'], // avoid pre-bundling issues
},
ssr: {
noExternal: ['@dynamic-labs/sdk-react-core']
noExternal: ['@dynamic-labs/sdk-react-core'], // keep SSR-friendly
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
'@': path.resolve(__dirname, './src'), // alias for src
},
},
});