Update Dockerfile for correct directory structure
Browse files- Dockerfile +57 -31
    	
        Dockerfile
    CHANGED
    
    | @@ -1,50 +1,77 @@ | |
| 1 | 
            -
            #  | 
| 2 | 
            -
            FROM node:20.11-alpine3.19 AS  | 
| 3 |  | 
| 4 | 
            -
            #  | 
| 5 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 6 |  | 
| 7 | 
            -
            #  | 
| 8 | 
            -
             | 
|  | |
|  | |
| 9 |  | 
| 10 | 
            -
            #  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
|  | |
| 14 |  | 
| 15 | 
            -
            #  | 
| 16 | 
            -
             | 
|  | |
|  | |
|  | |
| 17 | 
             
                yarn add code-inspector-plugin
         | 
| 18 |  | 
| 19 | 
            -
            # Copy  | 
| 20 | 
             
            COPY web/ .
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            # Build web app
         | 
| 23 | 
             
            RUN yarn build
         | 
| 24 |  | 
| 25 | 
            -
            # Python  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 26 | 
             
            FROM python:3.10-slim-bookworm
         | 
| 27 |  | 
| 28 | 
            -
            # Install  | 
| 29 | 
            -
            RUN apt | 
|  | |
|  | |
| 30 | 
             
                nodejs \
         | 
| 31 | 
             
                npm \
         | 
| 32 | 
            -
                 | 
| 33 | 
            -
                rm -rf /var/lib/apt/lists/*
         | 
| 34 |  | 
| 35 | 
            -
            # Set working directory
         | 
| 36 | 
             
            WORKDIR /app
         | 
| 37 |  | 
| 38 | 
            -
            # Copy  | 
|  | |
| 39 | 
             
            COPY api/ /app/api/
         | 
| 40 |  | 
| 41 | 
            -
            #  | 
| 42 | 
            -
            WORKDIR /app/api
         | 
| 43 | 
            -
            RUN pip install --no-cache-dir poetry && \
         | 
| 44 | 
            -
                poetry config virtualenvs.create false && \
         | 
| 45 | 
            -
                poetry install --no-dev
         | 
| 46 | 
            -
             | 
| 47 | 
            -
            # Copy built web files from builder stage
         | 
| 48 | 
             
            COPY --from=web-builder /app/web/.next /app/web/.next
         | 
| 49 | 
             
            COPY --from=web-builder /app/web/public /app/web/public
         | 
| 50 | 
             
            COPY --from=web-builder /app/web/node_modules /app/web/node_modules
         | 
| @@ -63,9 +90,8 @@ ENV FLASK_APP=app.py \ | |
| 63 | 
             
            # Expose ports
         | 
| 64 | 
             
            EXPOSE 3000 5001
         | 
| 65 |  | 
| 66 | 
            -
            #  | 
| 67 | 
             
            COPY docker/entrypoint.sh /entrypoint.sh
         | 
| 68 | 
             
            RUN chmod +x /entrypoint.sh
         | 
| 69 |  | 
| 70 | 
            -
            # Start services
         | 
| 71 | 
             
            CMD ["/entrypoint.sh"]
         | 
|  | |
| 1 | 
            +
            # Base stage with shared configuration
         | 
| 2 | 
            +
            FROM node:20.11-alpine3.19 AS base
         | 
| 3 |  | 
| 4 | 
            +
            # Configure build environment
         | 
| 5 | 
            +
            ENV NODE_OPTIONS="--max_old_space_size=2048" \
         | 
| 6 | 
            +
                NEXT_TELEMETRY_DISABLED=1 \
         | 
| 7 | 
            +
                NODE_ENV=production \
         | 
| 8 | 
            +
                PYTHONDONTWRITEBYTECODE=1 \
         | 
| 9 | 
            +
                POETRY_NO_INTERACTION=1 \
         | 
| 10 | 
            +
                POETRY_VIRTUALENVS_CREATE=false \
         | 
| 11 | 
            +
                POETRY_CACHE_DIR=/cache/poetry
         | 
| 12 |  | 
| 13 | 
            +
            # Web builder stage
         | 
| 14 | 
            +
            FROM base AS web-builder
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            WORKDIR /app/web
         | 
| 17 |  | 
| 18 | 
            +
            # Setup build cache
         | 
| 19 | 
            +
            RUN --mount=type=cache,target=/root/.yarn \
         | 
| 20 | 
            +
                --mount=type=cache,target=/root/.npm \
         | 
| 21 | 
            +
                yarn config set cache-folder /root/.yarn && \
         | 
| 22 | 
            +
                npm config set cache /root/.npm
         | 
| 23 |  | 
| 24 | 
            +
            # Copy package files and install dependencies
         | 
| 25 | 
            +
            COPY web/package.json web/yarn.lock ./
         | 
| 26 | 
            +
            RUN --mount=type=cache,target=/root/.yarn \
         | 
| 27 | 
            +
                --mount=type=cache,target=/root/.npm \
         | 
| 28 | 
            +
                yarn install --frozen-lockfile --network-timeout 300000 && \
         | 
| 29 | 
             
                yarn add code-inspector-plugin
         | 
| 30 |  | 
| 31 | 
            +
            # Copy source and build
         | 
| 32 | 
             
            COPY web/ .
         | 
|  | |
|  | |
| 33 | 
             
            RUN yarn build
         | 
| 34 |  | 
| 35 | 
            +
            # Python builder stage
         | 
| 36 | 
            +
            FROM python:3.10-slim-bookworm AS python-builder
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            # Install build dependencies
         | 
| 39 | 
            +
            RUN --mount=type=cache,target=/var/cache/apt \
         | 
| 40 | 
            +
                apt-get update && \
         | 
| 41 | 
            +
                apt-get install -y --no-install-recommends \
         | 
| 42 | 
            +
                build-essential \
         | 
| 43 | 
            +
                && rm -rf /var/lib/apt/lists/*
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            WORKDIR /app/api
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            # Install and configure poetry
         | 
| 48 | 
            +
            RUN --mount=type=cache,target=/root/.cache/pip \
         | 
| 49 | 
            +
                pip install --no-cache-dir poetry
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            # Copy Python files and install dependencies
         | 
| 52 | 
            +
            COPY api/pyproject.toml api/poetry.lock ./
         | 
| 53 | 
            +
            RUN --mount=type=cache,target=/root/.cache/pypoetry \
         | 
| 54 | 
            +
                poetry config virtualenvs.create false && \
         | 
| 55 | 
            +
                poetry install --no-dev --no-interaction --no-ansi
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            # Final stage
         | 
| 58 | 
             
            FROM python:3.10-slim-bookworm
         | 
| 59 |  | 
| 60 | 
            +
            # Install runtime dependencies
         | 
| 61 | 
            +
            RUN --mount=type=cache,target=/var/cache/apt \
         | 
| 62 | 
            +
                apt-get update && \
         | 
| 63 | 
            +
                apt-get install -y --no-install-recommends \
         | 
| 64 | 
             
                nodejs \
         | 
| 65 | 
             
                npm \
         | 
| 66 | 
            +
                && rm -rf /var/lib/apt/lists/*
         | 
|  | |
| 67 |  | 
|  | |
| 68 | 
             
            WORKDIR /app
         | 
| 69 |  | 
| 70 | 
            +
            # Copy Python environment
         | 
| 71 | 
            +
            COPY --from=python-builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
         | 
| 72 | 
             
            COPY api/ /app/api/
         | 
| 73 |  | 
| 74 | 
            +
            # Copy web build artifacts
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 75 | 
             
            COPY --from=web-builder /app/web/.next /app/web/.next
         | 
| 76 | 
             
            COPY --from=web-builder /app/web/public /app/web/public
         | 
| 77 | 
             
            COPY --from=web-builder /app/web/node_modules /app/web/node_modules
         | 
|  | |
| 90 | 
             
            # Expose ports
         | 
| 91 | 
             
            EXPOSE 3000 5001
         | 
| 92 |  | 
| 93 | 
            +
            # Setup entrypoint
         | 
| 94 | 
             
            COPY docker/entrypoint.sh /entrypoint.sh
         | 
| 95 | 
             
            RUN chmod +x /entrypoint.sh
         | 
| 96 |  | 
|  | |
| 97 | 
             
            CMD ["/entrypoint.sh"]
         | 
 
			
