-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
67 lines (50 loc) · 1.56 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Use node as base image for frontend build
FROM node:18.18-slim AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
RUN npm install --force
# Copy frontend source code
COPY frontend/ .
# Build frontend
RUN npm run build
# Use Python for final image
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# Install poetry
RUN pip install poetry
# Copy backend pyproject.toml and poetry.lock
ADD backend/ ./backend/
# Configure poetry to create virtualenv in project directory
WORKDIR /app/backend
RUN poetry config virtualenvs.create true && \
poetry config virtualenvs.in-project true && \
poetry install --no-dev --no-interaction --no-ansi
# Copy backend source code
COPY backend/ .
# Copy built frontend from previous stage
WORKDIR /app
COPY --from=frontend-builder /app/frontend/.next ./frontend/.next
COPY --from=frontend-builder /app/frontend/package*.json ./frontend/
COPY --from=frontend-builder /app/frontend/node_modules ./frontend/node_modules
COPY --from=frontend-builder /app/frontend/public ./frontend/public
# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=1905
# Expose frontend port
EXPOSE 1905
# Create start script
RUN echo '#!/bin/bash\n\
cd /app/backend && poetry install && poetry run start &\
cd /app/frontend && npm start' > /app/start.sh && \
chmod +x /app/start.sh
# Set working directory
WORKDIR /app
# Start both services
CMD ["/app/start.sh"]