Skip to content

Commit 1fa1848

Browse files
Capstone Complete
1 parent ba4ebad commit 1fa1848

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

server/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Use Python 3.12 slim as the base image
2+
FROM python:3.12.0-slim-bookworm
3+
4+
# Set environment variables to improve Python performance
5+
ENV PYTHONBUFFERED=1
6+
ENV PYTHONWRITEBYTECODE=1
7+
8+
# Define application directory
9+
ENV APP=/app
10+
11+
# Set the working directory
12+
WORKDIR $APP
13+
14+
# Copy the requirements.txt file
15+
COPY requirements.txt $APP/
16+
17+
# Install dependencies
18+
RUN pip3 install --no-cache-dir -r requirements.txt
19+
20+
# Copy the application files
21+
COPY . $APP/
22+
23+
# Expose the application port
24+
EXPOSE 8000
25+
26+
# Ensure entrypoint script is executable
27+
RUN chmod +x /app/entrypoint.sh
28+
29+
# Set entrypoint script
30+
ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]
31+
32+
# Start the application using Gunicorn
33+
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-muhammadalih/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)