# Use an official Python runtime as a parent image FROM python:3.10-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV TZ=Asia/Seoul # Install system dependencies including PostgreSQL client 16 RUN apt-get update && \ apt-get install -y --no-install-recommends \ gnupg \ lsb-release \ wget \ ca-certificates \ tzdata \ gpg \ lftp && \ # Add PostgreSQL Apt Repository # Download the key wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ # Dearmor the key and save to the keyring directory gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \ # Set correct permissions for the keyring file chmod 644 /usr/share/keyrings/postgresql-archive-keyring.gpg && \ # Add the repository source, signed by the keyring sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \ # Update again after adding repo apt-get update && \ # Install specific client version apt-get install -y --no-install-recommends \ postgresql-client-16 && \ # Configure timezone ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ # Clean up (remove build dependencies) apt-get purge -y --auto-remove wget gnupg lsb-release ca-certificates gpg && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Install Python dependencies # Using requirements.txt is generally better, but for a simple script: RUN pip install --no-cache-dir schedule pytz # Set the working directory in the container WORKDIR /app # Copy the Python script into the container COPY db/backup.py . # Ensure .ssh directory exists (still good practice, though key might not be used) # RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh # No longer needed for SSH keys # Command to run the application CMD ["python", "backup.py"]