Published on

Burp Suite: Turn off the Network Captive Portal in Firefox

Authors

nixpack.toml

[start]
cmd = "fastapi run main.py --port 8000"

https://app.coolify.io/project/cws0os8kgs0448k80wwsswks/environment/c0s0c004sggk8kwgsgkskw8g/application/n4wwk4c4wcgogg0kg4ww0wkg

Alternative

Create Dockerfile

Put it in directory

Configure Coolify with Github App

Configure & Add Environment Variables

React frontend with Vite and Shadcn/ui

# ---- Build Stage ----
FROM node:20-alpine AS build

# Set working directory
WORKDIR /app

# Copy package.json and package-lock.json (if it exists).
# Using a wildcard package*.json ensures that if package-lock.json is present
# in the build context, it's copied and used for the npm install step.
# This helps leverage Docker's layer caching effectively.
# If package-lock.json is not present, this command will not fail and will copy package.json.
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Build the application
# The build script is defined in package.json ("build": "tsc -b && vite build")
RUN npm run build

# ---- Serve Stage ----
FROM nginx:1.25-alpine

# Copy the build output from the build stage to Nginx's html directory
COPY --from=build /app/dist /usr/share/nginx/html

# Copy the custom Nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]

Fastapi Backend

# Use an official Python runtime as a parent image
FROM python:3.11-slim-bullseye

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=off
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV PIP_DEFAULT_TIMEOUT=100
ENV GOOGLE_API_KEY="dummy_value_please_replace_at_runtime"

# System dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    libpq-dev \
    libffi-dev \
    ffmpeg \
    # Playwright dependencies
    libnss3 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0 libgbm-dev libasound2 \
    libxshmfence1 libxfixes3 libxrandr2 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 \
    # Pillow dependencies
    libtiff5 libjpeg62-turbo libopenjp2-7 libwebp6 \
    curl \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user and group
ARG USERNAME=appuser
ARG USER_UID=1001
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME && \
    useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

# Set the working directory in the container
WORKDIR /app

# Create and activate virtual environment
RUN python -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"

# Upgrade pip and install wheel & setuptools
RUN pip install --no-cache-dir pip==23.3.1 wheel==0.41.2 setuptools==68.0.0

# Copy the requirements file into the container
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Install Playwright browsers and dependencies as root
RUN playwright install --with-deps

# Run crawl4ai setup if needed
RUN crawl4ai-setup

# Copy the rest of the application code into the container
COPY ./app ./app
COPY ./prisma ./prisma

# Change ownership of the /app directory to the non-root user
RUN chown -R $USERNAME:$USERNAME /app

# Create .cache directory for appuser and set proper permissions
RUN mkdir -p /home/$USERNAME/.cache && \
    chown -R $USERNAME:$USERNAME /home/$USERNAME/.cache

# Switch to the non-root user BEFORE generating Prisma client
USER $USERNAME

# Set HOME environment variable to ensure Prisma uses the correct cache directory
ENV HOME=/home/$USERNAME

# Generate Prisma client as appuser - this ensures binaries are cached in appuser's home
RUN prisma generate

# Expose the port the app runs on
EXPOSE 8000

# Define the command to run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]