-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
49 lines (32 loc) · 1.37 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#Stage 1:Build Frontend
FROM node:18 as build-stage
WORKDIR /code
COPY ./Frontend/ecommerce_inventory/ /code/Frontend/ecommerce_inventory/
WORKDIR /code/Frontend/ecommerce_inventory
#Installing packages
RUN npm install
#Building the frontend
RUN npm run build
#Stage 2:Build Backend
FROM python:3.11.0
#Set Environment Variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /code
#Copy Django Project to the container
COPY ./Backend/EcommerceInventory /code/Backend/EcommerceInventory/
#Install the required packages
RUN pip install -r ./Backend/EcommerceInventory/requirements.txt
#Copy the frontend build to the Django project
COPY --from=build-stage ./code/Frontend/ecommerce_inventory/build /code/Backend/EcommerceInventory/static/
COPY --from=build-stage ./code/Frontend/ecommerce_inventory/build/static /code/Backend/EcommerceInventory/static/
COPY --from=build-stage ./code/Frontend/ecommerce_inventory/build/index.html /code/Backend/EcommerceInventory/EcommerceInventory/templates/index.html
#Run Django Migration Command
RUN python ./Backend/EcommerceInventory/manage.py migrate
#Run Django Collectstatic Command
RUN python ./Backend/EcommerceInventory/manage.py collectstatic --no-input
#Expose the port
EXPOSE 80
WORKDIR /code/Backend/EcommerceInventory
#Run the Django Server
CMD ["gunicorn","EcommerceInventory.wsgi:application","--bind","0.0.0.0:8000"]