FROM python:3
RUN apt update
RUN apt-get install -y npm
COPY . .
WORKDIR /frontend
RUN npm install
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN npm run build
WORKDIR /backend
RUN pip install --no-cache-dir -r requirements.txt
RUN mkdir -p src/static \
&& cd src/static \
&& cp -r /frontend/build/* . \
&& mkdir -p css js \
&& mv static/css/* css/ \
&& mv static/js/* js/
RUN mkdir -p /data
ENV DB_PATH=/data/db.db
ENV FLASK_RUN_PORT=5001
ENV FLASK_APP src/app
EXPOSE 5001
CMD flask run --host=0.0.0.0