Switch to using tailwind.css build and subsequently switch to docker file
This commit is contained in:
47
Dockerfile
Normal file
47
Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
||||
# Stage 1: Node.js for TailwindCSS build
|
||||
FROM node:16-alpine as tailwind-builder
|
||||
|
||||
# Set working directory for Tailwind build
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only the necessary files for TailwindCSS build
|
||||
COPY package.json package-lock.json ./
|
||||
COPY ./app/templates ./app/templates
|
||||
COPY tailwind.config.js ./
|
||||
COPY ./app/static/css/tailwind.css ./app/static/css/tailwind.css
|
||||
|
||||
# Install Node.js dependencies
|
||||
RUN npm install
|
||||
|
||||
# Build TailwindCSS assets
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Python for Flask app
|
||||
FROM python:3.9-slim
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
libpq-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory for Flask app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only necessary application files
|
||||
COPY requirements.txt ./
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy the rest of the application files
|
||||
COPY . .
|
||||
|
||||
# Copy the built TailwindCSS assets from the first stage
|
||||
COPY --from=tailwind-builder /app/app/static/css/tailwind.css ./app/static/css/tailwind.css
|
||||
|
||||
# Expose the port Flask will run on
|
||||
EXPOSE 5000
|
||||
|
||||
# Command to run the Flask app
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:create_app()"]
|
||||
Reference in New Issue
Block a user