feature(integrate FE,BE):

This commit is contained in:
Devoalda 2023-10-30 13:28:44 +08:00
parent 2ac61c8f38
commit d71950b17f
3 changed files with 20 additions and 15 deletions

View File

@ -1,10 +1,5 @@
FROM python:3.10
# Install Netcat
RUN apt-get update && \
apt-get -y install netcat-traditional && \
apt-get clean
ENV PYTHONUNBUFFERED 1
WORKDIR /code

View File

@ -1,15 +1,17 @@
# React Frontend
FROM node as react-build
# Stage 1: Build React Frontend
FROM node AS frontend-build
WORKDIR /frontend
COPY safeshare-frontend/ ./
COPY package*.json ./
RUN npm install
# Start the react app
CMD ["npm", "start"]
COPY . .
FROM python:3.10 as backend-build
RUN npm run build
# Stage 2: Build Django Backend
FROM python:3.10
ENV PYTHONUNBUFFERED 1
@ -20,6 +22,9 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . /code/
RUN chmod a+x start.sh
# Stage 3: Combine React and Django
COPY --from=frontend-build /frontend/build /code/frontend/build
EXPOSE 3000 8000
CMD ["./start.sh"]

View File

@ -10,7 +10,12 @@ python manage.py runserver 0.0.0.0:8000 &
sleep 2
# 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
tail -f django_server.log trash_collector.log