Files
plex-playlist/Dockerfile.cicd
Cliff Hill 75db646c13
Some checks failed
Tests / Build and Push CICD Image (push) Failing after 21m2s
Tests / Prettier Format Check (push) Has been skipped
Tests / Trailing Whitespace Check (push) Has been skipped
Tests / End of File Check (push) Has been skipped
Tests / YAML Syntax Check (push) Has been skipped
Tests / TOML Syntax Check (push) Has been skipped
Tests / Mixed Line Ending Check (push) Has been skipped
Tests / Ruff Linting (push) Has been skipped
Tests / Ruff Format Check (push) Has been skipped
Tests / Darglint Docstring Check (push) Has been skipped
Tests / Backend Doctests (push) Has been skipped
Tests / Integration Tests (push) Has been skipped
Tests / Pyright Type Check (push) Has been skipped
Tests / No Docstring Types Check (push) Has been skipped
Tests / TSDoc Lint Check (push) Has been skipped
Tests / Backend Tests (push) Has been skipped
Tests / Frontend Tests (push) Has been skipped
Tests / TOML Formatting Check (push) Has been skipped
Tests / ESLint Check (push) Has been skipped
Tests / TypeScript Type Check (push) Has been skipped
Tests / End-to-End Tests (push) Has been skipped
Making apt-fast work right.
Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
2025-10-27 10:52:10 -04:00

138 lines
4.4 KiB
Docker

# CICD Setup - Clean base image with development tools only
FROM ubuntu:22.04
# Set timezone and make installs non-interactive
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York
# Configure timezone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install apt-fast for faster downloads
RUN apt-get update && apt-get install -y \
software-properties-common \
&& add-apt-repository -y ppa:apt-fast/stable \
&& apt-get update && apt-get install -y \
apt-fast \
&& rm -rf /var/lib/apt/lists/*
# Configure apt-fast for non-interactive use
RUN echo 'apt-fast apt-fast/maxdownloads string 10' | debconf-set-selections && \
echo 'apt-fast apt-fast/dlflag boolean true' | debconf-set-selections && \
echo 'apt-fast apt-fast/aptmanager string apt-get' | debconf-set-selections
# Install system dependencies using apt-fast
RUN apt-fast update && apt-fast install -y \
git \
curl \
ca-certificates \
software-properties-common \
build-essential \
openssh-client \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Install Python 3.13
RUN add-apt-repository -y ppa:deadsnakes/ppa \
&& apt-fast update && apt-fast install -y \
python3.13 \
python3.13-venv \
python3.13-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 24
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
&& apt-fast update && apt-fast install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Enable corepack for yarn and set up Yarn Berry
RUN corepack enable \
&& corepack prepare yarn@stable --activate \
&& yarn set version berry
# Install uv package manager globally
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Accept build arguments for Git checkout
ARG SSH_PRIVATE_KEY
ARG GITHUB_SHA
# Set working directory
WORKDIR /workspace
# Set up SSH and clone repository
RUN if [ -n "$SSH_PRIVATE_KEY" ]; then \
mkdir -p ~/.ssh && \
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa && \
chmod 600 ~/.ssh/id_rsa && \
echo "Host *" > ~/.ssh/config && \
echo " StrictHostKeyChecking no" >> ~/.ssh/config && \
echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config && \
chmod 600 ~/.ssh/config && \
ssh-keyscan -p 2222 dogar.darkhelm.org >> ~/.ssh/known_hosts 2>/dev/null; \
fi
# Clone repository
RUN GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
git clone --depth 1 --branch main \
ssh://git@dogar.darkhelm.org:2222/DarkHelm.org/plex-playlist.git . && \
if [ -n "$GITHUB_SHA" ]; then \
git checkout "$GITHUB_SHA" 2>/dev/null || echo "Using main branch HEAD"; \
fi
# Clean up SSH key for security
RUN rm -rf ~/.ssh
# Set up Python environment for backend
WORKDIR /workspace/backend
ENV VIRTUAL_ENV=/workspace/backend/.venv
RUN uv venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install backend dev dependencies
RUN uv sync --dev
# Install backend package in development mode
RUN uv pip install -e .
# Set up frontend dependencies
WORKDIR /workspace/frontend
RUN yarn install --immutable
# Verify all tools are working with the project
RUN cd /workspace/backend && \
echo "=== Backend Tools Verification ===" && \
uv run ruff --version && \
uv run pyright --version && \
uv run darglint --version && \
uv run pytest --version && \
uv run yamllint --version && \
uv run toml-sort --version && \
uv run xdoctest --version
RUN cd /workspace/frontend && \
echo "=== Frontend Tools Verification ===" && \
yarn eslint --version && \
yarn prettier --version && \
yarn tsc --version && \
yarn vitest --version
# Create a script to set up SSH for git operations (if needed for updates)
RUN echo '#!/bin/bash' > /usr/local/bin/setup-ssh && \
echo 'mkdir -p ~/.ssh' >> /usr/local/bin/setup-ssh && \
echo 'echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa' >> /usr/local/bin/setup-ssh && \
echo 'chmod 600 ~/.ssh/id_rsa' >> /usr/local/bin/setup-ssh && \
echo 'ssh-keyscan -H github.com >> ~/.ssh/known_hosts 2>/dev/null' >> /usr/local/bin/setup-ssh && \
echo 'ssh-keyscan -H dogar.darkhelm.org >> ~/.ssh/known_hosts 2>/dev/null' >> /usr/local/bin/setup-ssh && \
chmod +x /usr/local/bin/setup-ssh
# Set Python path for backend
ENV PYTHONPATH=/workspace/backend/src:/workspace/backend
# Set working directory back to root
WORKDIR /workspace
# Default to bash
SHELL ["/bin/bash", "-c"]
CMD ["/bin/bash"]