Skip to content

Commit 5d80675

Browse files
committed
module 5 complete
1 parent d0fb388 commit 5d80675

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
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-kyleaguilar2/dealership:latest
24+
imagePullPolicy: Always
25+
name: dealership
26+
ports:
27+
- containerPort: 8000
28+
protocol: TCP
29+
restartPolicy: Always

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)