Auto-generated by Trail System
This commit is contained in:
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM python:3.9-slim as build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --user -r requirements.txt
|
||||||
|
|
||||||
|
FROM python:3.9-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /root/.local /root/.local
|
||||||
|
COPY . .
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends adduser && adduser --disabled-password --gecos '' appuser && chown -R appuser /app
|
||||||
|
USER appuser
|
||||||
|
ENV PATH=/root/.local/bin:$PATH
|
||||||
|
CMD ["python", "app.py"]
|
||||||
21
app.py
Normal file
21
app.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def home():
|
||||||
|
"""Handle the root endpoint, returns 'Todo List' as a string."""
|
||||||
|
return 'Todo List'
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def not_found(e):
|
||||||
|
"""Handle 404 Not Found errors with a custom message."""
|
||||||
|
return 'Page not found', 404
|
||||||
|
|
||||||
|
@app.errorhandler(500)
|
||||||
|
def server_error(e):
|
||||||
|
"""Handle 500 Internal Server Error with a custom message."""
|
||||||
|
return 'Internal server error', 500
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=False)
|
||||||
6
chart/Chart.yaml
Normal file
6
chart/Chart.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: todo-app
|
||||||
|
description: A simple Flask-based Todo App hosted in a Docker container with Helm orchestration. The application exposes a single endpoint at '/' that returns 'Todo List'. Uses minimal dependencies and follows 12-factor principles for containerized deployment.
|
||||||
|
type: application
|
||||||
|
version: 0.1.0
|
||||||
|
appVersion: "1.0.0"
|
||||||
24
chart/templates/deployment.yaml
Normal file
24
chart/templates/deployment.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: flask-todo-app
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: flask-todo-app
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: flask-todo-app
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: flask-todo-app
|
||||||
|
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
|
||||||
|
ports:
|
||||||
|
- containerPort: 5000
|
||||||
|
env:
|
||||||
|
- name: FLASK_APP
|
||||||
|
value: "{{ .Values.env.FLASK_APP }}"
|
||||||
|
- name: DEBUG
|
||||||
|
value: "{{ .Values.env.DEBUG }}"
|
||||||
9
chart/templates/service.yaml
Normal file
9
chart/templates/service.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.service.name }}
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
selector:
|
||||||
|
app: {{ .Values.app.name }}
|
||||||
8
chart/values.yaml
Normal file
8
chart/values.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
image:
|
||||||
|
repository: flask-todo-app
|
||||||
|
tag: latest
|
||||||
|
service:
|
||||||
|
port: 5000
|
||||||
|
env:
|
||||||
|
FLASK_APP: app.py
|
||||||
|
DEBUG: "False"
|
||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Flask
|
||||||
Reference in New Issue
Block a user