add release w/ migration

3193c9a · gmorell · 2022-07-28 05:45

15 files +196 -1

Files changed

modified .gitlab-ci.yml
+1 −1
@@ -16,7 +16,7 @@ build-master:
16 16 # - boston
17 17 script:
18 18 - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
19 − - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE --registry-mirror e0.registry.gng.io
19 + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE --registry-mirror e0.registry.gng.io --registry-mirror eu0.regi.kube.gmp.io
20 20 # - docker build -t "$CI_REGISTRY_IMAGE" .
21 21 # - docker push "$CI_REGISTRY_IMAGE"
22 22
added app.yml
+150 −0
@@ -0,0 +1,150 @@
1 +#cat <<EOF | kubectl apply -f -
2 +apiVersion: v1
3 +kind: Namespace
4 +metadata:
5 + name: apollos-crib
6 +---
7 +apiVersion: apps/v1
8 +kind: Deployment
9 +metadata:
10 + name: apollos-crib
11 + namespace: apollos-crib
12 + labels:
13 + name: apollos-crib
14 + keel.sh/policy: force
15 + keel.sh/trigger: poll
16 +spec:
17 + replicas: 1
18 + selector:
19 + matchLabels:
20 + name: apollos-crib
21 + strategy:
22 + type: RollingUpdate
23 + rollingUpdate:
24 + maxSurge: 1
25 + maxUnavailable: 0
26 + template:
27 + metadata:
28 + labels:
29 + name: apollos-crib
30 + annotations:
31 + spec:
32 + containers:
33 + - image: r.g.gmp.io/lambentri/apollos-crib:latest
34 + imagePullPolicy: Always
35 + env:
36 + # - name: RAVEN_DSN
37 + # valueFrom:
38 + # secretKeyRef:
39 + # name: wed4u-secrets
40 + # key: sentrydsn
41 + - name: PORT
42 + value: "8080"
43 +
44 + - name: SECRET_KEY_BASE
45 + valueFrom:
46 + secretKeyRef:
47 + name: elixir-args
48 + key: secret_key_base
49 +
50 + - name: POSTGRES_HOST
51 + valueFrom:
52 + secretKeyRef:
53 + name: postgres-auth
54 + key: host
55 +
56 + - name: POSTGRES_PORT
57 + valueFrom:
58 + secretKeyRef:
59 + name: postgres-auth
60 + key: port
61 +
62 + - name: POSTGRES_USER
63 + valueFrom:
64 + secretKeyRef:
65 + name: postgres-auth
66 + key: user
67 +
68 + - name: POSTGRES_PASSWORD
69 + valueFrom:
70 + secretKeyRef:
71 + name: postgres-auth
72 + key: password
73 +
74 + - name: AMQP_USER
75 + valueFrom:
76 + secretKeyRef:
77 + name: rabbitmq-default-user
78 + key: username
79 +
80 + - name: AMQP_PASSWORD
81 + valueFrom:
82 + secretKeyRef:
83 + name: rabbitmq-default-user
84 + key: password
85 +
86 + - name: DATABASE_URL
87 + value: ecto://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/csnap
88 +
89 + - name: RABBIT_URL
90 + value: amqp://$(AMQP_USER_USER):$(AMQP_PASS)@rabbitmq:5672
91 +
92 + name: apollos-crib
93 + ports:
94 + - containerPort: 8080
95 +
96 + imagePullSecrets:
97 + - name: gitlabgmp
98 +---
99 +apiVersion: v1
100 +kind: Service
101 +metadata:
102 + name: apollos-crib-svc
103 + namespace: apollos-crib
104 +spec:
105 + ports:
106 + - port: 80
107 + targetPort: 8080
108 + protocol: TCP
109 + selector:
110 + app: apollos-crib
111 +---
112 +apiVersion: networking.k8s.io/v1
113 +kind: Ingress
114 +metadata:
115 + name: apollos-crib-ingress
116 + namespace: apollos-crib
117 + annotations:
118 + cert-manager.io/cluster-issuer: letsencrypt-prod
119 + kubernetes.io/ingress.class: "nginx"
120 +spec:
121 + tls:
122 + - hosts:
123 + # CHANGE ME
124 + - ac.gmp.io
125 + - apollos-crib.gmp.io
126 + secretName: apollos-crib-tls
127 + rules:
128 + # CHANGE ME
129 + - host: ac.gmp.io
130 + http:
131 + paths:
132 + - path: /
133 + pathType: Prefix
134 + backend:
135 + service:
136 + name: apollos-crib-svc
137 + port:
138 + number: 80
139 + - host: apollos-crib.gmp.io
140 + http:
141 + paths:
142 + - path: /
143 + pathType: Prefix
144 + backend:
145 + service:
146 + name: apollos-crib-svc
147 + port:
148 + number: 80
149 +
150 +# EOF
added apps/room_sanctum/lib/room_sanctum/release.ex
+28 −0
@@ -0,0 +1,28 @@
1 +defmodule RoomSanctum.Release do
2 + @moduledoc """
3 + Used for executing DB release tasks when run in production without Mix
4 + installed.
5 + """
6 + @app :room_sanctum
7 +
8 + def migrate do
9 + load_app()
10 +
11 + for repo <- repos() do
12 + {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
13 + end
14 + end
15 +
16 + def rollback(repo, version) do
17 + load_app()
18 + {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
19 + end
20 +
21 + defp repos do
22 + Application.fetch_env!(@app, :ecto_repos)
23 + end
24 +
25 + defp load_app do
26 + Application.load(@app)
27 + end
28 +end
added apps/room_sanctum/rel/overlays/bin/migrate
+3 −0
@@ -0,0 +1,3 @@
1 +#!/bin/sh
2 +cd -P -- "$(dirname -- "$0")"
3 +exec ./room_sanctum eval RoomSanctum.Release.migrate
added apps/room_sanctum/rel/overlays/bin/migrate.bat
+1 −0
@@ -0,0 +1 @@
1 +call "%~dp0\room_sanctum" eval RoomSanctum.Release.migrate
added apps/room_sanctum/rel/overlays/bin/server
+3 −0
@@ -0,0 +1,3 @@
1 +#!/bin/sh
2 +cd -P -- "$(dirname -- "$0")"
3 +PHX_SERVER=true exec ./room_sanctum start
added apps/room_sanctum/rel/overlays/bin/server.bat
+2 −0
@@ -0,0 +1,2 @@
1 +set PHX_SERVER=true
2 +call "%~dp0\room_sanctum" start
added rabbit.yml
+8 −0
@@ -0,0 +1,8 @@
1 +---
2 +apiVersion: rabbitmq.com/v1beta1
3 +kind: RabbitmqCluster
4 +metadata:
5 + name: rabbitmq
6 + namespace: apollos-crib
7 +spec:
8 + replicas: 1

Parents: 58cd43e