diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..36b6792 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Use an official Python image as the base +FROM python:3.12-slim + +# Install Node.js, npm, and cron +RUN apt-get update && apt-get install -y \ + curl \ + cron \ + && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup backend +WORKDIR /app/backend +COPY backend/* . + +RUN pip install -r requirements.txt + +# Setup frontend +WORKDIR /app/frontend +COPY frontend/* . + +# Setup docker +WORKDIR /app/docker +COPY docker/* /app/docker/ + +RUN chmod +x entry.sh +RUN chmod 0644 cronfile + +WORKDIR /app + +EXPOSE 5173 + +# Command to start cron and the backend +CMD ["sh", "-c", "/app/docker/entry.sh"] diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..6d8abca --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,2 @@ +requests +uvicorn diff --git a/docker/crontab b/docker/crontab new file mode 100644 index 0000000..702de83 --- /dev/null +++ b/docker/crontab @@ -0,0 +1,2 @@ +*/1 * * * * python3 /app/backend/get_notifications.py +*/5 * * * * python3 /app/backend/run_scripts.py diff --git a/docker/entry.sh b/docker/entry.sh new file mode 100644 index 0000000..a7345f9 --- /dev/null +++ b/docker/entry.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Navigate to the frontend directory and start the Svelte app +cd frontend +npm run build +npm run dev & + +# Navigate back to the root directory +cd .. + +# Setup exec venv +cd backend/exec_folder +python3 -m venv venv +cd ../.. + +# Start the backend using uvicorn +uvicorn backend.backend:app --host 0.0.0.0 --port 8000 & + +# Start the cron daemon +crontab docker/cronfile +cron -f