diff --git a/safeshare/Dockerfile b/safeshare/Dockerfile index 4c05e08..9e0a8ae 100644 --- a/safeshare/Dockerfile +++ b/safeshare/Dockerfile @@ -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 diff --git a/safeshare/DockerfileFEBE b/safeshare/DockerfileFEBE index e8efd1a..7eec803 100644 --- a/safeshare/DockerfileFEBE +++ b/safeshare/DockerfileFEBE @@ -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 -CMD ["./start.sh"] \ No newline at end of file +EXPOSE 3000 8000 + +CMD ["./start.sh"] diff --git a/safeshare/start.sh b/safeshare/start.sh index 654da13..18482da 100755 --- a/safeshare/start.sh +++ b/safeshare/start.sh @@ -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