-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
44 lines (34 loc) · 1.26 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
# Backend stage
FROM python:3.11-alpine AS backend
RUN apk add --no-cache gcc musl-dev libffi-dev
WORKDIR /app/backend
COPY ./back .
# Create and activate virtual environment with all dependencies
RUN python -m venv venv && \
. venv/bin/activate && \
pip install --no-cache-dir -r req.txt fastapi uvicorn
# Frontend stage
FROM node:20 AS frontend
WORKDIR /app/frontend
COPY ./front .
RUN npm install
RUN npm run build
# Final stage
FROM python:3.11-alpine
RUN apk add --no-cache gcc musl-dev libffi-dev nodejs npm postgresql postgresql-contrib
WORKDIR /app
# Copy backend with venv and install dependencies in final stage
COPY --from=backend /app/backend /app/backend
RUN . /app/backend/venv/bin/activate && \
pip install --no-cache-dir -r /app/backend/req.txt fastapi uvicorn
# Copy frontend build
COPY --from=frontend /app/frontend /app/frontend
# Set up PostgreSQL directories
RUN mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql/data && \
mkdir -p /run/postgresql && chown -R postgres:postgres /run/postgresql
# Install dotenv globally for frontend
RUN npm install -g dotenv
EXPOSE 8000 3000 5432
COPY ./docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]