File size: 1,601 Bytes
e7f5703
ecdcf52
e7f5703
 
 
2fe3317
40c02d6
e7f5703
 
2fe3317
e7f5703
 
 
 
 
 
 
ecdcf52
 
e7f5703
 
 
ecdcf52
e7f5703
 
ecdcf52
e7f5703
2fe3317
ecdcf52
40c02d6
2fe3317
 
 
 
 
ecdcf52
 
e7f5703
ecdcf52
e7f5703
 
f26d3fa
ecdcf52
 
 
e7f5703
 
ecdcf52
e7f5703
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM oven/bun:latest as frontend-builder

# Set working directory for frontend
WORKDIR /build
# Copy frontend package files from the correct path
COPY frontend/package.json frontend/bun.lockb* ./
# Install ALL dependencies (including Next.js)
RUN bun install
# Copy frontend source
COPY frontend/ ./
# Build the Next.js app
RUN bun run build

FROM oven/bun:latest

# Use the existing user with UID 1000 (the 'bun' user)
USER 1000
WORKDIR /app

# Copy package files and install dependencies for backend
COPY --chown=1000:1000 package.json bun.lockb* ./
RUN bun install --production

# Copy backend application code
COPY --chown=1000:1000 src/ ./src/

# Create frontend directory structure
RUN mkdir -p ./frontend

# Copy built Next.js app AND node_modules from builder stage
COPY --from=frontend-builder --chown=1000:1000 /build/.next ./frontend/.next
COPY --from=frontend-builder --chown=1000:1000 /build/public ./frontend/public
COPY --from=frontend-builder --chown=1000:1000 /build/package.json ./frontend/package.json
COPY --from=frontend-builder --chown=1000:1000 /build/next.config.mjs ./frontend/next.config.mjs
COPY --from=frontend-builder --chown=1000:1000 /build/node_modules ./frontend/node_modules

# Create necessary directories and set permissions
RUN mkdir -p /app/logs /app/temp

# Expose ports for both services (backend: 5000, frontend: 7860)
EXPOSE 5000
EXPOSE 7860

# Set environment variables
ENV NODE_ENV=production
ENV BACKEND_PORT=5000
ENV FRONTEND_PORT=7860

# Start both services using a start script
COPY --chown=1000:1000 start.sh ./
RUN chmod +x start.sh
CMD ["./start.sh"]