adds interactivity to services.swpc.noaa.gov/images/animations. uses prefect for a backend to scrape images generate movies with ffmpeg. flask frontend at /iframe + proxy server via bare domain and API access via /api.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

6 months ago
# Use Python 3.10.11 slim image as the base image
FROM python:3.10.11-slim
# Set environment variables to avoid writing .pyc files and buffering stdout and stderr
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Create a new user 'user' with UID and GID of 1000
RUN groupadd -g 1000 user && \
useradd -m -s /bin/bash -u 1000 -g user user
# Set environment variables for the user install
ENV PATH=/home/user/.local/bin:$PATH
# Install system dependencies as root
RUN apt-get update && \
apt-get install -y --no-install-recommends make ffmpeg dumb-init && \
rm -rf /var/lib/apt/lists/*
# Set the home directory
WORKDIR /home/user/
RUN chown -R user:user /home/user
# Switch to non-root user before copying files and installing Python packages
USER user
# Copy the requirements file to /tmp and install Python dependencies with user flag
COPY --chown=user:user requirements.txt /tmp/requirements.txt
RUN python -m pip install --upgrade pip
RUN pip install --no-cache-dir --user -r /tmp/requirements.txt
# APPLICATION SETUP
# Copy the default profiles file and set the appropriate permissions
COPY --chown=user:user profiles.default.toml /home/user/.prefect/profiles.toml
# Copy the application files
COPY --chown=user:user app ./app
COPY --chown=user:user noaa_animate.py .
COPY --chown=user:user start.sh .
COPY --chown=user:user init_db.py .
RUN chmod +x start.sh
RUN mkdir -p out
RUN python init_db.py /home/user/.prefect/prefect.db
# Set the correct ownership (recursively) for /app
# Already owned by user due to --chown in COPY commands
# Define the entrypoint and the commands to execute
ENTRYPOINT ["dumb-init", "--"]
CMD ["./start.sh"]