forked from SeaCello/FlashLearn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
57 lines (41 loc) · 1.47 KB
/
Copy pathdockerfile
File metadata and controls
57 lines (41 loc) · 1.47 KB
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
# Etapa 1: Build
FROM python:3.13-slim AS builder
# Variáveis de ambiente para o build
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
NODE_ENV=development \
NPM_BIN_PATH=/usr/bin/npm \
DJANGO_SETTINGS_MODULE=webapp.settings \
DEBUG=False
WORKDIR /app
# Instalar dependências do sistema e Node.js
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
build-essential \
git \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copiar requirements e instalar dependências Python
COPY requirements.txt .
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
COPY . .
# Instalar dependências do Node.js e compilar Tailwind
WORKDIR /app/app/theme/static_src
RUN npm install --include=dev && npm run build
WORKDIR /app/app
RUN python manage.py collectstatic --noinput --skip-checks
# Etapa 2: Imagem final
FROM python:3.13-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
NODE_ENV=production
WORKDIR /app
COPY requirements.txt .
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt && pip install gunicorn
COPY --from=builder /app /app
RUN echo '#!/bin/bash\ncd /app/app\npython manage.py migrate\nexec gunicorn webapp.wsgi:application --bind 0.0.0.0:8000' > /app/entrypoint.sh \
&& chmod +x /app/entrypoint.sh
EXPOSE 8000
CMD ["/app/entrypoint.sh"]