AxL95 commited on
Commit
c95db5d
·
verified ·
1 Parent(s): f5b48bb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -7
Dockerfile CHANGED
@@ -2,8 +2,8 @@ FROM node:20-alpine AS builder
2
  RUN apk add --no-cache libc6-compat
3
  WORKDIR /app
4
 
5
- # Install dependencies based on the preferred package manager
6
- COPY frontend .
7
  RUN \
8
  if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
9
  elif [ -f package-lock.json ]; then npm ci; \
@@ -11,27 +11,34 @@ RUN \
11
  else echo "Lockfile not found." && exit 1; \
12
  fi
13
 
 
 
14
  RUN npm run build
 
15
  FROM python:3.10-slim AS backend
16
  WORKDIR /app
17
 
 
18
  RUN apt-get update && apt-get install --no-install-recommends -y \
19
  git ffmpeg curl gnupg \
20
  && apt-get clean && rm -rf /var/lib/apt/lists/*
21
 
22
  RUN useradd -m -u 1000 user
23
 
24
- COPY ./requirements.txt .
25
- RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
 
26
 
27
  USER user
28
  ENV HOME=/home/user \
29
  PATH=/home/user/.local/bin:$PATH
30
 
31
-
32
  WORKDIR $HOME/app
 
 
33
  COPY --from=builder /app/build ./static
34
- COPY . .
35
 
36
- CMD ["python", "app.py"]
 
37
 
 
 
2
  RUN apk add --no-cache libc6-compat
3
  WORKDIR /app
4
 
5
+ # Copy only package files first to leverage caching
6
+ COPY frontend/package*.json frontend/yarn*.lock ./
7
  RUN \
8
  if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
9
  elif [ -f package-lock.json ]; then npm ci; \
 
11
  else echo "Lockfile not found." && exit 1; \
12
  fi
13
 
14
+ # Copy frontend source files after dependencies are installed
15
+ COPY frontend/ .
16
  RUN npm run build
17
+
18
  FROM python:3.10-slim AS backend
19
  WORKDIR /app
20
 
21
+ # Simplify apt-get command to essential packages
22
  RUN apt-get update && apt-get install --no-install-recommends -y \
23
  git ffmpeg curl gnupg \
24
  && apt-get clean && rm -rf /var/lib/apt/lists/*
25
 
26
  RUN useradd -m -u 1000 user
27
 
28
+ # Copy only requirements first for better caching
29
+ COPY backend/requirements.txt .
30
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
31
 
32
  USER user
33
  ENV HOME=/home/user \
34
  PATH=/home/user/.local/bin:$PATH
35
 
 
36
  WORKDIR $HOME/app
37
+
38
+ # Copy built frontend from builder stage
39
  COPY --from=builder /app/build ./static
 
40
 
41
+ # Copy backend files last
42
+ COPY backend/ .
43
 
44
+ CMD ["python", "app.py"]