2025-02-06 20:31:39 -08:00
|
|
|
# First stage: Base build environment
|
2025-01-02 17:39:26 -08:00
|
|
|
FROM debian:stable-slim AS build
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Install required dependencies
|
2025-01-02 17:39:26 -08:00
|
|
|
RUN apt-get update && \
|
2025-02-06 20:31:39 -08:00
|
|
|
apt-get install -y git && \
|
|
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Ensure the 'games' directory exists
|
|
|
|
RUN mkdir -p /home/mesh/bbs/games
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Set working directory
|
|
|
|
WORKDIR /home/mesh/bbs
|
|
|
|
|
|
|
|
# Copy project files including 'games' directory
|
|
|
|
COPY . /home/mesh/bbs/
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Second stage: Final runtime environment
|
|
|
|
FROM python:alpine
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Add a non-root user for security
|
2025-01-02 17:39:26 -08:00
|
|
|
RUN adduser --disabled-password mesh
|
2025-02-06 20:31:39 -08:00
|
|
|
|
|
|
|
# Ensure working directory
|
2025-01-02 17:39:26 -08:00
|
|
|
RUN mkdir -p /home/mesh/bbs
|
|
|
|
WORKDIR /home/mesh/bbs
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Copy files from the build stage
|
|
|
|
COPY --from=build /home/mesh/bbs /home/mesh/bbs/
|
|
|
|
|
2025-01-02 17:39:26 -08:00
|
|
|
# Install Python dependencies
|
|
|
|
RUN pip install --no-cache-dir --break-system-packages -r requirements.txt
|
2024-06-27 10:25:35 -07:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Ensure the 'games' directory exists in runtime container
|
|
|
|
RUN mkdir -p /home/mesh/bbs/games
|
|
|
|
|
|
|
|
# Set user to mesh
|
|
|
|
USER mesh
|
|
|
|
|
|
|
|
# Expose necessary ports
|
|
|
|
EXPOSE 8080
|
2025-01-02 17:39:26 -08:00
|
|
|
|
2025-02-06 20:31:39 -08:00
|
|
|
# Start the server
|
|
|
|
CMD ["python", "server.py"]
|
2024-06-27 10:25:35 -07:00
|
|
|
|