Skip to content

Commit b804034

Browse files
committed
Add Dockerfile, Kubernetes deployment, service, and kustomization files for production setup
1 parent 5b63510 commit b804034

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Use official Python base image
2+
FROM python:3-slim
3+
4+
# Set environment variables
5+
ENV PYTHONDONTWRITEBYTECODE=1
6+
ENV PYTHONUNBUFFERED=1
7+
8+
# Set work directory
9+
WORKDIR /app
10+
11+
# Install system dependencies
12+
RUN apt-get update \
13+
&& apt-get install -y --no-install-recommends gcc build-essential \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Install Python dependencies
17+
COPY pyproject.toml poetry.lock* requirements.txt* ./
18+
RUN pip install --upgrade pip \
19+
&& pip install -r requirements.txt
20+
21+
# Copy project
22+
COPY . .
23+
24+
# Expose port for Flask app
25+
EXPOSE 5000
26+
27+
# Default command to run Flask app
28+
CMD ["python", "-m", "flask_app.app"]

k8s/base/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+
name: python-dsa
5+
labels:
6+
app: python-dsa
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: python-dsa
12+
template:
13+
metadata:
14+
labels:
15+
app: python-dsa
16+
spec:
17+
containers:
18+
- name: python-dsa
19+
image: us-central1-docker.pkg.dev/kame-457417/kame-house-images/python-dsa:latest
20+
imagePullPolicy: Always
21+
ports:
22+
- containerPort: 5000
23+
resources:
24+
requests:
25+
cpu: "100m"
26+
memory: "128Mi"
27+
limits:
28+
cpu: "500m"
29+
memory: "256Mi"

k8s/base/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- deployment.yaml
6+
- service.yaml

k8s/base/service.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: python-dsa
5+
labels:
6+
app: python-dsa
7+
spec:
8+
selector:
9+
app: python-dsa
10+
ports:
11+
- protocol: TCP
12+
port: 80
13+
targetPort: 5000
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: prod
4+
resources:
5+
- ../../base

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

0 commit comments

Comments
 (0)