Empty / Dockerfile
r.go
wddwdwdwdwd
8d258cf
# Declare build arguments globally before any FROM statement.
ARG PYTHON_VERSION=3.12.1
# ---------------------------
# Stage 1: Node build environment
# ---------------------------
FROM node:20-alpine3.16 AS node-builder
WORKDIR /app
# Copy the entire project from the build context.
COPY . .
# Install required Alpine packages.
RUN apk add --no-cache \
font-noto font-noto-cjk font-noto-extra \
gcompat libstdc++ libuuid \
vips-dev build-base jpeg-dev pango-dev cairo-dev \
imagemagick libssl1.1 && \
ln -s /lib/libresolv.so.2 /usr/lib/libresolv.so.2
# Install Node dependencies and install ts-node globally.
RUN npm install && \
npm install -g ts-node \
npx playwright install-deps \
npx playwright install
# ---------------------------
# Stage 2: Python runtime environment
# ---------------------------
FROM python:${PYTHON_VERSION}-slim
# Update apt and install system dependencies AND Node.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
fontconfig fonts-dejavu fonts-dejavu-core fonts-dejavu-extra \
fonts-liberation fonts-noto \
git curl gnupg && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
ENV npm_config_cache=/tmp/.npm
# Make sure that directory exists and is writable
RUN mkdir -p /tmp/.npm && chmod -R 777 /tmp/.npm
RUN mkdir -p /tmp/cache_dir && chmod -R 777 /tmp/cache_dir
# Set environment variable.
ENV PORT=7860
WORKDIR /app
# Copy the entire project from the build context.
COPY . .
# If the environment variables are set, clone the private repository.
RUN --mount=type=secret,id=GITHUB_REPO,required=true \
--mount=type=secret,id=GITHUB_USERNAME,required=true \
--mount=type=secret,id=GITHUB_TOKEN,required=true \
if [ -n "$(cat /run/secrets/GITHUB_USERNAME)" ] && [ -n "$(cat /run/secrets/GITHUB_TOKEN)" ] && [ -n "$(cat /run/secrets/GITHUB_REPO)" ]; then \
echo "Cloning private repository into 'social_session'"; \
git clone https://$(cat /run/secrets/GITHUB_USERNAME):$(cat /run/secrets/GITHUB_TOKEN)@github.com/$(cat /run/secrets/GITHUB_USERNAME)/$(cat /run/secrets/GITHUB_REPO).git social_session; \
else \
echo "Skipping git clone: GITHUB_USERNAME, TOKEN, or GITHUB_REPO not set"; \
fi
# Expose the port used by the ASGI server.
EXPOSE 7860
# Install your Python dependencies from requirements.txt.
RUN pip install -r requirements.txt
# Start the server using hypercorn.
CMD ["python", "-m", "hypercorn", "main:app", "-b", "0.0.0.0:7860", "-w", "8", "--keep-alive", "600"]