From 98ed38337f7318695006fbe487a4a6ff89b34037 Mon Sep 17 00:00:00 2001
From: thijsheijden <hi@thijsheijden.nl>
Date: Mon, 28 Mar 2022 14:50:47 +0200
Subject: [PATCH] feat: added deployment and nginx.conf

---
 .gitlab-ci.yml   |  2 +-
 deployment.yml   | 35 +++++++++++++++++++++++++++++++++++
 nginx/nginx.conf | 16 ++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 deployment.yml
 create mode 100644 nginx/nginx.conf

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fcd29fb2b..3a29f10fe 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -64,7 +64,7 @@ build-docker:
   only:
     - main
   script:
-    - docker build --progress plain -t $CI_PROJECT_NAME-webserver-service:latest .
+    - docker build --progress plain -t datastropheregistry.azurecr.io/frontend:latest:latest .
   # after_script:
   #   - docker login datastropheregistry.azurecr.io -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
   #   - if [[ ! -z $CI_COMMIT_BRANCH+x ]]; then DOCKER_TAG=$CI_COMMIT_BRANCH; else DOCKER_TAG=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME; fi
diff --git a/deployment.yml b/deployment.yml
new file mode 100644
index 000000000..fc945c187
--- /dev/null
+++ b/deployment.yml
@@ -0,0 +1,35 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: frontend-webserver-deployment
+  labels:
+    app: frontend-webserver
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: frontend-webserver
+  template:
+    metadata:
+      labels:
+        app: frontend-webserver
+    spec:
+      containers:
+        - name: container
+          image: datastropheregistry.azurecr.io/frontend:latest
+          ports:
+            - containerPort: 3000
+      imagePullSecrets:
+        - name: docker-regcred
+
+---
+kind: Service
+apiVersion: v1
+metadata:
+  name: frontend-webserver
+spec:
+  selector:
+    app: frontend-webserver
+  ports:
+    - port: 3000
+      targetPort: 80
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
new file mode 100644
index 000000000..ef2e21a89
--- /dev/null
+++ b/nginx/nginx.conf
@@ -0,0 +1,16 @@
+server {
+  listen 80;
+
+  location / {
+    root   /usr/share/nginx/html;
+    index  index.html index.htm;
+    try_files $uri $uri/ /index.html;
+  }
+
+  error_page 500 502 503 504 /50x.html;
+
+  location = /50x.html {
+      root /usr/share/nginx/html;
+  }
+
+}
-- 
GitLab