update dockerfile, css build and alpine images
Some checks failed
Build and Push Madplaner / build (push) Failing after 21s
Some checks failed
Build and Push Madplaner / build (push) Failing after 21s
This commit is contained in:
35
Dockerfile
35
Dockerfile
@@ -1,21 +1,34 @@
|
||||
FROM python:3.11-slim
|
||||
# --- STAGE 1: CSS Builder ---
|
||||
FROM node:18-alpine AS css-builder
|
||||
WORKDIR /app
|
||||
COPY package*.json tailwind.config.js ./
|
||||
COPY ./static/src/input.css ./static/src/input.css
|
||||
COPY ./templates ./templates
|
||||
RUN npm install && npx tailwindcss -i ./static/src/input.css -o ./static/dist/css/output.css --minify
|
||||
# --- STAGE 2: Final App (Python) ---
|
||||
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
# --- STAGE 2: Python Builder (Compile dependencies) ---
|
||||
FROM python:3.11-alpine AS py-builder
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
# Install into a local folder to copy easily
|
||||
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
|
||||
|
||||
# --- STAGE 3: Final Minimal Image ---
|
||||
FROM python:3.11-alpine
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
# Copy only the installed python packages from py-builder
|
||||
COPY --from=py-builder /install /usr/local
|
||||
# Copy only the compiled CSS from css-builder
|
||||
COPY --from=css-builder /app/static/dist/css/output.css ./static/dist/css/output.css
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
# Clean up any unneeded source files to save space
|
||||
RUN rm -rf static/src tailwind.config.js package*.json requirements.txt
|
||||
# Initialize DB, then start Gunicorn
|
||||
CMD python -c "from app import app, db; app.app_context().push(); db.create_all()" && \
|
||||
gunicorn --bind 0.0.0.0:5000 app:app
|
||||
Reference in New Issue
Block a user