Skip to content

Commit b751e39

Browse files
committed
Initial commit
0 parents  commit b751e39

14 files changed

Lines changed: 563 additions & 0 deletions

File tree

.diploi/helm/app-ingress.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: ingress
5+
annotations:
6+
kubernetes.io/ingress.class: traefik
7+
spec:
8+
tls:
9+
- hosts:
10+
- {{ .Values.hosts.app }}
11+
secretName: tls-secret
12+
rules:
13+
- host: {{ .Values.hosts.app }}
14+
http:
15+
paths:
16+
- path: '/'
17+
pathType: Prefix
18+
backend:
19+
service:
20+
name: app
21+
port:
22+
number: 8000

.diploi/helm/app-service.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: app
5+
spec:
6+
ports:
7+
- port: 8000
8+
name: app
9+
selector:
10+
app: app

.diploi/helm/app.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apiVersion: apps/v1
2+
{{- if eq .Values.stage "development"}}
3+
kind: StatefulSet
4+
{{- else }}
5+
kind: Deployment
6+
{{- end }}
7+
metadata:
8+
name: app
9+
labels:
10+
app: app
11+
spec:
12+
selector:
13+
matchLabels:
14+
app: app
15+
{{- if eq .Values.stage "development"}}
16+
serviceName: app
17+
{{- else }}
18+
strategy:
19+
type: RollingUpdate
20+
rollingUpdate:
21+
maxUnavailable: 25%
22+
maxSurge: 25%
23+
{{- end }}
24+
replicas: {{ ternary 1 0 .Values.enabled }}
25+
template:
26+
metadata:
27+
labels:
28+
app: app
29+
spec:
30+
terminationGracePeriodSeconds: 10
31+
imagePullSecrets:
32+
- name: diploi-pull-secret
33+
{{- if eq .Values.stage "development"}}
34+
securityContext:
35+
runAsUser: 1000
36+
runAsGroup: 1000
37+
initContainers:
38+
- name: install-dependencies
39+
image: {{ .Values.images.app }}
40+
imagePullPolicy: Always
41+
command: |
42+
python -m venv .venv
43+
direnv allow
44+
pip install -r requirements.txt
45+
workingDir: /app/{{ .Values.identifier }}
46+
volumeMounts:
47+
- name: app-mount
48+
mountPath: /app
49+
{{- end }}
50+
containers:
51+
- name: app
52+
image: {{ .Values.images.app }}
53+
imagePullPolicy: Always
54+
ports:
55+
- containerPort: 8000
56+
{{- if eq .Values.stage "development" }}
57+
workingDir: /app/{{ .Values.identifier }}
58+
{{- end }}
59+
env:
60+
{{- range .Values.env }}
61+
- name: {{ .identifier }}
62+
value: {{ .value | quote }}
63+
{{- end }}
64+
volumeMounts:
65+
{{- if hasKey .Values.storage "code" }}
66+
- name: app-mount
67+
mountPath: /app
68+
{{- end }}
69+
volumes:
70+
{{- if hasKey .Values.storage "code" }}
71+
- name: app-mount
72+
hostPath:
73+
path: {{ .Values.storage.code.hostPath }}
74+
{{- end }}

.diploi/icon.svg

Lines changed: 54 additions & 0 deletions
Loading

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
layout python-venv .venv

.github/workflows/Prebuild.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Pre-Build
2+
3+
on:
4+
push:
5+
6+
env:
7+
REGISTRY: ghcr.io
8+
9+
jobs:
10+
production:
11+
name: 'Production'
12+
runs-on: ubuntu-latest
13+
permissions:
14+
packages: write
15+
steps:
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Docker meta
23+
id: meta
24+
uses: docker/metadata-action@v4
25+
with:
26+
images: ${{ env.REGISTRY }}/${{ github.repository }}
27+
28+
- name: 'Login to GitHub Container Registry'
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Set tags
36+
id: set-tags
37+
run: |
38+
TAGS="${{ steps.meta.outputs.tags }}"
39+
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
40+
TAGS="${TAGS},${{ env.REGISTRY }}/${{ github.repository }}:latest"
41+
fi
42+
echo "tags=$TAGS" >> $GITHUB_ENV
43+
44+
- name: Build and push
45+
uses: docker/build-push-action@v6
46+
with:
47+
push: ${{ github.event_name != 'pull_request' }}
48+
platforms: linux/arm64
49+
tags: ${{ env.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
52+
development:
53+
name: 'Development'
54+
runs-on: ubuntu-latest
55+
permissions:
56+
packages: write
57+
steps:
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Docker meta
65+
id: meta
66+
uses: docker/metadata-action@v4
67+
with:
68+
images: ${{ env.REGISTRY }}/${{ github.repository }}
69+
flavor: |
70+
suffix=-dev.
71+
72+
- name: 'Login to GitHub Container Registry'
73+
uses: docker/login-action@v3
74+
with:
75+
registry: ${{ env.REGISTRY }}
76+
username: ${{ github.actor }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Set tags
80+
id: set-tags
81+
run: |
82+
TAGS="${{ steps.meta.outputs.tags }}"
83+
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
84+
TAGS="${TAGS},${{ env.REGISTRY }}/${{ github.repository }}:latest"
85+
fi
86+
echo "tags=$TAGS" >> $GITHUB_ENV
87+
88+
- name: Build and push
89+
uses: docker/build-push-action@v6
90+
with:
91+
file: Dockerfile.dev
92+
push: ${{ github.event_name != 'pull_request' }}
93+
platforms: linux/arm64
94+
tags: ${{ env.tags }}
95+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)