Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5efb93ea68 | ||
|
|
1ee6b890ef | ||
|
|
18aab648c6 | ||
|
|
57328a7fc8 | ||
|
|
948569a659 | ||
|
|
50cdfd8180 | ||
|
|
8393efa3a6 | ||
|
|
b3db1816bb | ||
|
|
7123f4c389 | ||
|
|
477ddfe165 | ||
|
|
6bc472f7fe | ||
|
|
41f4549ffd | ||
|
|
7dd45cc2e8 | ||
|
|
8ec174b2c3 | ||
|
|
7868867908 | ||
|
|
d2bf889e1f | ||
|
|
a70aa8840f | ||
|
|
8404d43222 | ||
|
|
f31106dd29 | ||
|
|
fbd8b0e2a7 | ||
|
|
b04ef5a579 | ||
|
|
e01bf28646 | ||
|
|
f362194c5e | ||
|
|
bdc4c90705 | ||
|
|
b309e5fa4a |
@@ -36,15 +36,15 @@ deploy:
|
||||
- $CI_COMMIT_TAG
|
||||
stage: deploy
|
||||
image:
|
||||
name: debian:latest
|
||||
name: debian:10
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- echo $CI_REGISTRY_IMAGE
|
||||
- apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null
|
||||
- curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
|
||||
- chmod +x ./kubectl
|
||||
- envsubst < k8s/deploy.yaml > out.yaml
|
||||
- mv out.yaml k8s/deploy.yaml
|
||||
- ./kubectl apply -f k8s
|
||||
- mkdir /deploy
|
||||
- for f in $(find k8s -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
|
||||
- ./kubectl apply -f /deploy
|
||||
- ./kubectl rollout status deploy $DEPLOY
|
||||
- ./kubectl exec $(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}') -- python manage.py migrate
|
||||
- POD=$(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}')
|
||||
- ./kubectl exec $POD -- python manage.py migrate
|
||||
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@@ -5,7 +5,7 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Django",
|
||||
"name": "Test",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/manage.py",
|
||||
@@ -13,6 +13,17 @@
|
||||
"test",
|
||||
],
|
||||
"django": true
|
||||
},
|
||||
{
|
||||
"name": "Run Server",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/manage.py",
|
||||
"args": [
|
||||
"runserver",
|
||||
"--noreload"
|
||||
],
|
||||
"django": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,4 +8,10 @@ COPY manage.py manage.py
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
RUN useradd -ms /bin/bash django
|
||||
RUN chown -R django .
|
||||
|
||||
USER django
|
||||
RUN python manage.py collectstatic
|
||||
|
||||
CMD ["gunicorn","-b",":8000", "-w", "4", "config.wsgi"]
|
||||
24
README.md
Normal file
24
README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# CI Builder
|
||||
|
||||
My CI testing pipeline for a django project.
|
||||
|
||||
[](http://gitlab.ducoterra.net/ducoterra/ci_builder/-/commits/master)
|
||||
|
||||
## Django Environment Variables
|
||||
|
||||
### Django Secret
|
||||
|
||||
```bash
|
||||
kubectl create secret generic django-secrets --from-literal=SECRET_KEY=$(python -c "import secrets ; print(secrets.token_urlsafe(32))")
|
||||
```
|
||||
|
||||
### Django Allowed Hosts
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: test
|
||||
data:
|
||||
ALLOWED_HOSTS: localhost,test.ducoterra.net
|
||||
```
|
||||
@@ -20,13 +20,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'b8fi9=f-qj=@-#1iru34-f@a6pzfysgrf(1n_&d=ur%!1w$q*w'
|
||||
SECRET_KEY = os.getenv("SECRET_KEY")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ["localhost", "test.ducoterra.net"]
|
||||
DEBUG = True if os.getenv("DEBUG") == "True" else False
|
||||
|
||||
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "localhost").split(",")
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -122,3 +121,4 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
@@ -18,7 +18,7 @@ from django.urls import path, include
|
||||
from django.http import JsonResponse
|
||||
|
||||
urlpatterns = [
|
||||
path('', include('api.urls')),
|
||||
# path('api/', include('api.urls')),
|
||||
path('', include('ui.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
||||
6
k8s/configmap.yaml
Normal file
6
k8s/configmap.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: $DEPLOY
|
||||
data:
|
||||
ALLOWED_HOSTS: localhost,test.ducoterra.net
|
||||
@@ -1,22 +1,27 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: test
|
||||
name: $DEPLOY
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: test
|
||||
app: $DEPLOY
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: test
|
||||
app: $DEPLOY
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
- name: $DEPLOY
|
||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: $DEPLOY
|
||||
- secretRef:
|
||||
name: django-secrets
|
||||
volumeMounts:
|
||||
- mountPath: /app/db
|
||||
name: test
|
||||
name: $DEPLOY
|
||||
resources:
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
@@ -27,6 +32,6 @@ spec:
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
volumes:
|
||||
- name: test
|
||||
- name: $DEPLOY
|
||||
persistentVolumeClaim:
|
||||
claimName: test
|
||||
claimName: $DEPLOY
|
||||
@@ -3,7 +3,7 @@ kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
ingress.kubernetes.io/ssl-redirect: "true"
|
||||
name: test
|
||||
name: $DEPLOY
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
@@ -14,7 +14,7 @@ spec:
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: test
|
||||
serviceName: $DEPLOY
|
||||
servicePort: 8000
|
||||
|
||||
---
|
||||
@@ -22,7 +22,7 @@ spec:
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: test-external-tls
|
||||
name: $DEPLOY-external-tls
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
@@ -32,15 +32,15 @@ spec:
|
||||
- match: Host(`test.ducoterra.net`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: test-web
|
||||
port: 80
|
||||
- name: $DEPLOY
|
||||
port: 8000
|
||||
|
||||
---
|
||||
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: test-external-web
|
||||
name: $DEPLOY-external-web
|
||||
spec:
|
||||
entryPoints:
|
||||
- web
|
||||
@@ -48,7 +48,7 @@ spec:
|
||||
- match: Host(`test.ducoterra.net`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: test-web
|
||||
port: 80
|
||||
- name: $DEPLOY
|
||||
port: 8000
|
||||
middlewares:
|
||||
- name: httpsredirect
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: test
|
||||
name: $DEPLOY
|
||||
spec:
|
||||
storageClassName: nfs-encrypted
|
||||
accessModes:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: test
|
||||
name: $DEPLOY
|
||||
spec:
|
||||
selector:
|
||||
app: test
|
||||
app: $DEPLOY
|
||||
ports:
|
||||
- port: 8000
|
||||
targetPort: 8000
|
||||
@@ -5,6 +5,8 @@ import sys
|
||||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DEBUG', 'True')
|
||||
os.environ.setdefault('SECRET_KEY', 'SeVOOxOHISQZv82RfCPds0B2l8M6jGju4G8F-GcuSrc')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section, .container {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.disable-dbl-tap-zoom {
|
||||
touch-action: manipulation;
|
||||
}
|
||||
@@ -20,6 +20,7 @@ var count = document.getElementById("COUNT");
|
||||
|
||||
button.addEventListener("click", event => {
|
||||
button.disabled = true;
|
||||
button.classList.add("is-loading");
|
||||
fetch('/button', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -34,6 +35,7 @@ button.addEventListener("click", event => {
|
||||
count.innerText = data.pressed;
|
||||
}).finally(() => {
|
||||
button.disabled = false;
|
||||
button.classList.remove("is-loading");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<h1 class="title">
|
||||
The Button
|
||||
</h1>
|
||||
<button class="button is-primary" id="BUTTON">Press</button>
|
||||
<button class="button is-primary disable-dbl-tap-zoom" id="BUTTON">Press</button>
|
||||
</div>
|
||||
<div><br></div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user