Severian commited on
Commit
7ce37bf
1 Parent(s): 12e3afc

Update Dockerfile for correct directory structure

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -21
Dockerfile CHANGED
@@ -1,39 +1,57 @@
1
- # Use Python as base image since it's the main application runtime
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  FROM python:3.10-slim-bookworm
3
 
4
- # Install required system dependencies
5
  RUN apt-get update && apt-get install -y \
6
- curl \
7
  nodejs \
8
  npm \
9
- && rm -rf /var/lib/apt/lists/*
 
10
 
11
  # Set working directory
12
  WORKDIR /app
13
 
14
- # Copy application files
15
  COPY api/ /app/api/
16
- COPY web/ /app/web/
17
 
18
- # Install Python dependencies for API
19
  WORKDIR /app/api
20
- RUN pip install poetry && \
21
  poetry config virtualenvs.create false && \
22
- poetry install --no-dev
23
 
24
- # Install Node.js dependencies and build web frontend
25
- WORKDIR /app/web
26
- RUN npm install && \
27
- npm run build
28
 
29
  # Set environment variables
30
- ENV FLASK_APP=app.py
31
- ENV EDITION=SELF_HOSTED
32
- ENV DEPLOY_ENV=PRODUCTION
33
- ENV CONSOLE_API_URL=http://127.0.0.1:5001
34
- ENV CONSOLE_WEB_URL=http://127.0.0.1:3000
35
- ENV SERVICE_API_URL=http://127.0.0.1:5001
36
- ENV APP_WEB_URL=http://127.0.0.1:3000
 
37
 
38
  # Expose ports
39
  EXPOSE 3000 5001
@@ -42,5 +60,5 @@ EXPOSE 3000 5001
42
  COPY docker/entrypoint.sh /entrypoint.sh
43
  RUN chmod +x /entrypoint.sh
44
 
45
- # Start both API and web services
46
  CMD ["/entrypoint.sh"]
 
1
+ # Use Node.js as base image since it's needed for the web build
2
+ FROM node:20.11-alpine3.19 AS web-builder
3
+
4
+ # Set working directory for web
5
+ WORKDIR /app/web
6
+ COPY web/package*.json ./
7
+
8
+ # Install only production dependencies
9
+ RUN npm ci --only=production
10
+
11
+ # Copy web source files
12
+ COPY web/ .
13
+
14
+ # Build web app with optimizations
15
+ ENV NODE_ENV=production
16
+ ENV NEXT_TELEMETRY_DISABLED=1
17
+ RUN npm run build
18
+
19
+ # Python base image for final stage
20
  FROM python:3.10-slim-bookworm
21
 
22
+ # Install only essential dependencies
23
  RUN apt-get update && apt-get install -y \
 
24
  nodejs \
25
  npm \
26
+ --no-install-recommends && \
27
+ rm -rf /var/lib/apt/lists/*
28
 
29
  # Set working directory
30
  WORKDIR /app
31
 
32
+ # Copy API files
33
  COPY api/ /app/api/
 
34
 
35
+ # Install Python dependencies efficiently
36
  WORKDIR /app/api
37
+ RUN pip install --no-cache-dir poetry && \
38
  poetry config virtualenvs.create false && \
39
+ poetry install --no-dev --no-interaction --no-ansi
40
 
41
+ # Copy built web files from builder stage
42
+ COPY --from=web-builder /app/web/.next /app/web/.next
43
+ COPY --from=web-builder /app/web/public /app/web/public
44
+ COPY --from=web-builder /app/web/node_modules /app/web/node_modules
45
 
46
  # Set environment variables
47
+ ENV FLASK_APP=app.py \
48
+ EDITION=SELF_HOSTED \
49
+ DEPLOY_ENV=PRODUCTION \
50
+ CONSOLE_API_URL=http://127.0.0.1:5001 \
51
+ CONSOLE_WEB_URL=http://127.0.0.1:3000 \
52
+ SERVICE_API_URL=http://127.0.0.1:5001 \
53
+ APP_WEB_URL=http://127.0.0.1:3000 \
54
+ NODE_ENV=production
55
 
56
  # Expose ports
57
  EXPOSE 3000 5001
 
60
  COPY docker/entrypoint.sh /entrypoint.sh
61
  RUN chmod +x /entrypoint.sh
62
 
63
+ # Start services
64
  CMD ["/entrypoint.sh"]