feature(integrate FE,BE):
This commit is contained in:
parent
2ac61c8f38
commit
d71950b17f
|
@ -1,10 +1,5 @@
|
||||||
FROM python:3.10
|
FROM python:3.10
|
||||||
|
|
||||||
# Install Netcat
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get -y install netcat-traditional && \
|
|
||||||
apt-get clean
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
# React Frontend
|
# Stage 1: Build React Frontend
|
||||||
FROM node as react-build
|
FROM node AS frontend-build
|
||||||
|
|
||||||
WORKDIR /frontend
|
WORKDIR /frontend
|
||||||
|
|
||||||
COPY safeshare-frontend/ ./
|
COPY package*.json ./
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Start the react app
|
COPY . .
|
||||||
CMD ["npm", "start"]
|
|
||||||
|
|
||||||
FROM python:3.10 as backend-build
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Build Django Backend
|
||||||
|
FROM python:3.10
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
@ -20,6 +22,9 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY . /code/
|
COPY . /code/
|
||||||
|
|
||||||
RUN chmod a+x start.sh
|
# Stage 3: Combine React and Django
|
||||||
|
COPY --from=frontend-build /frontend/build /code/frontend/build
|
||||||
|
|
||||||
CMD ["./start.sh"]
|
EXPOSE 3000 8000
|
||||||
|
|
||||||
|
CMD ["./start.sh"]
|
||||||
|
|
|
@ -10,7 +10,12 @@ python manage.py runserver 0.0.0.0:8000 &
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Start the custom management command to run the trash collector
|
# Start the custom management command to run the trash collector
|
||||||
python manage.py start_trash_collector
|
python manage.py start_trash_collector &
|
||||||
|
|
||||||
|
# Start the React frontend (assuming you have a command to start it in your package.json)
|
||||||
|
cd /frontend
|
||||||
|
npm start &
|
||||||
|
cd ..
|
||||||
|
|
||||||
# Optionally, you can monitor the logs in real-time if needed
|
# Optionally, you can monitor the logs in real-time if needed
|
||||||
tail -f django_server.log trash_collector.log
|
tail -f django_server.log trash_collector.log
|
||||||
|
|
Loading…
Reference in New Issue