# syntax=docker/dockerfile:1 # ---- Stage 1: Build Next.js frontend ---- FROM node:20-slim AS frontend-build WORKDIR /frontend COPY werkout-frontend/package.json werkout-frontend/package-lock.json ./ RUN npm ci COPY werkout-frontend/ ./ ENV NEXT_PUBLIC_API_URL= RUN rm -rf .next && npm run build # ---- Stage 2: Final image (Python + Node runtime) ---- FROM python:3.9.13 ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # System deps RUN apt-get update && apt-get install -y \ swig libssl-dev dpkg-dev netcat ffmpeg \ supervisor curl \ && rm -rf /var/lib/apt/lists/* # Install Node.js 20 for Next.js runtime RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Python deps RUN pip install -U pip WORKDIR /code COPY requirements.txt /code/ RUN pip install -r requirements.txt # Copy Django project COPY . /code/ # Copy built frontend (overwrite source with built version) COPY --from=frontend-build /frontend/.next /code/werkout-frontend/.next COPY --from=frontend-build /frontend/node_modules /code/werkout-frontend/node_modules # Collect static files RUN /code/manage.py collectstatic --noinput || true # Supervisor config COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf EXPOSE 8000 3000 CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]