Update Dockerfile for correct directory structure
Browse files- Dockerfile +39 -21
Dockerfile
CHANGED
|
@@ -1,39 +1,57 @@
|
|
| 1 |
-
# Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
FROM python:3.10-slim-bookworm
|
| 3 |
|
| 4 |
-
# Install
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
-
curl \
|
| 7 |
nodejs \
|
| 8 |
npm \
|
| 9 |
-
&&
|
|
|
|
| 10 |
|
| 11 |
# Set working directory
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
-
# Copy
|
| 15 |
COPY api/ /app/api/
|
| 16 |
-
COPY web/ /app/web/
|
| 17 |
|
| 18 |
-
# Install Python dependencies
|
| 19 |
WORKDIR /app/api
|
| 20 |
-
RUN pip install poetry && \
|
| 21 |
poetry config virtualenvs.create false && \
|
| 22 |
-
poetry install --no-dev
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
# Set environment variables
|
| 30 |
-
ENV FLASK_APP=app.py
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 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
|
| 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"]
|