Skip to content

Commit 53e7a6e

Browse files
committed
containerize
1 parent 8cc5be8 commit 53e7a6e

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

server/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.12.0-slim-bookworm
2+
3+
ENV PYTHONBUFFERED 1
4+
ENV PYTHONWRITEBYTECODE 1
5+
6+
ENV APP=/app
7+
8+
# Change the workdir.
9+
WORKDIR $APP
10+
11+
# Install the requirements
12+
COPY requirements.txt $APP
13+
14+
RUN pip3 install -r requirements.txt
15+
16+
# Copy the rest of the files
17+
COPY . $APP
18+
19+
EXPOSE 8000
20+
21+
RUN chmod +x /app/entrypoint.sh
22+
23+
ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]
24+
25+
CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]

server/deployment.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
run: dealership
6+
name: dealership
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
run: dealership
12+
strategy:
13+
rollingUpdate:
14+
maxSurge: 25%
15+
maxUnavailable: 25%
16+
type: RollingUpdate
17+
template:
18+
metadata:
19+
labels:
20+
run: dealership
21+
spec:
22+
containers:
23+
- image: us.icr.io/sn-labs-cmaisy010822/dealership:latest
24+
imagePullPolicy: Always
25+
name: dealership
26+
ports:
27+
- containerPort: 8000
28+
protocol: TCP
29+
restartPolicy: Always

server/djangoapp/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
backend_url ="https://cmaisy010822-3030.theiadockernext-0-labs-prod-theiak8s-4-tor01.proxy.cognitiveclass.ai"
2-
sentiment_analyzer_url="https://sentianalyzer.21jfrov8t2bz.us-south.codeengine.appdomain.cloud/"
2+
sentiment_analyzer_url="https://sentianalyzer.21n1woj7t5ov.us-south.codeengine.appdomain.cloud/"

server/djangoproj/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
path('register/', TemplateView.as_view(template_name="index.html")),
3030
path('dealers/', TemplateView.as_view(template_name="index.html")),
3131
path(
32-
'dealer/int:dealer_id',
33-
TemplateView.as_view(template_name="index.html"),
32+
'dealer/int:dealer_id',
33+
TemplateView.as_view(template_name="index.html")
3434
),
3535
path(
3636
'postreview/int:dealer_id',
37-
TemplateView.as_view(template_name="index.html"),
37+
TemplateView.as_view(template_name="index.html")
3838
),
3939
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

server/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
# Make migrations and migrate the database.
4+
echo "Making migrations and migrating the database. "
5+
python manage.py makemigrations --noinput
6+
python manage.py migrate --noinput
7+
python manage.py collectstatic --noinput
8+
exec "$@"

0 commit comments

Comments
 (0)