File size: 1,437 Bytes
3ff1109
 
 
ecf6eee
 
 
 
 
 
 
3ff1109
 
 
 
 
 
 
 
 
 
 
 
 
 
91b97ba
3ff1109
 
c592550
3ff1109
 
 
 
3984df8
 
 
5b90ba4
 
aa9b446
3984df8
 
 
 
 
46c767a
 
5b90ba4
 
 
3984df8
3ff1109
 
2c73ab2
9c1a7ef
3ff1109
2c73ab2
9c1a7ef
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
53
54
55
56
# Use Python 3.11 slim image
FROM python:3.11-slim

# Install Node.js and npm
RUN apt-get update && apt-get install -y \
    curl \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Create data directory with proper permissions before switching user
RUN mkdir -p /data && chown user:user /data

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy requirements with correct ownership
COPY --chown=user requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy all frontend files first
COPY --chown=user frontend $HOME/app/frontend/

# Set up frontend
WORKDIR $HOME/app/frontend

# Create necessary Next.js directories if they don't exist
RUN mkdir -p src/app

# Install and build frontend
RUN npm install
RUN npm run build

# Return to app directory
WORKDIR $HOME/app

# Copy the remaining application code with correct ownership
COPY --chown=user . .

# Expose only FastAPI port
EXPOSE 3000

# Run Next.js in background and FastAPI as main process
CMD ["sh", "-c", "npm run start --prefix frontend & uvicorn backend.main:app --host 0.0.0.0 --port 3000"]