diff --git a/app/Dockerfile b/app/Dockerfile index 1850e4e0..09c06581 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -2,7 +2,6 @@ FROM nginx:1.23-alpine-slim RUN apk add --update nodejs npm - WORKDIR /usr/share/build RUN mkdir -p /usr/share/build/src \ @@ -16,8 +15,10 @@ COPY *.json /usr/share/build/ RUN npm install RUN npm install -g @oracle/ojet-cli -RUN npx ojet build web --release +RUN ojet build web --release + +RUN cp -R /usr/share/build/web/* /usr/share/nginx/html/ EXPOSE 80 -RUN cp -R /usr/share/build/web/* /usr/share/nginx/html/ \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/deploy/k8s/app/app-svc.yaml b/deploy/k8s/app/app-svc.yaml new file mode 100644 index 00000000..3d6cacfe --- /dev/null +++ b/deploy/k8s/app/app-svc.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: app + name: app +spec: + ports: + - port: 80 + protocol: TCP + targetPort: 80 + selector: + app: app \ No newline at end of file diff --git a/deploy/k8s/app/app.yaml b/deploy/k8s/app/app.yaml new file mode 100644 index 00000000..2a8c9070 --- /dev/null +++ b/deploy/k8s/app/app.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: app + name: app +spec: + replicas: 1 + selector: + matchLabels: + app: app + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + template: + metadata: + labels: + app: app + spec: + containers: + - image: app + name: app + readinessProbe: + httpGet: + scheme: HTTP + path: /index.html + port: 80 + initialDelaySeconds: 10 + periodSeconds: 5 + ports: + - containerPort: 80 + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: 250m + memory: 521Mi + imagePullSecrets: + - name: ocir-secret \ No newline at end of file diff --git a/deploy/k8s/app/kustomization.yaml b/deploy/k8s/app/kustomization.yaml new file mode 100644 index 00000000..fe280da3 --- /dev/null +++ b/deploy/k8s/app/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - app.yaml + - app-svc.yaml +namespace: backend \ No newline at end of file diff --git a/deploy/k8s/ingress/ingress.yaml b/deploy/k8s/ingress/ingress.yaml index 27faecd5..6c49d0f1 100644 --- a/deploy/k8s/ingress/ingress.yaml +++ b/deploy/k8s/ingress/ingress.yaml @@ -23,17 +23,17 @@ spec: name: backend port: number: 8080 - - path: /summary - pathType: Prefix - backend: - service: - name: web - port: - number: 80 + # - path: /summary + # pathType: Prefix + # backend: + # service: + # name: web + # port: + # number: 80 - path: / pathType: Prefix backend: service: - name: web + name: app port: number: 80 \ No newline at end of file diff --git a/deploy/k8s/overlays/prod/kustomization.yaml.mustache b/deploy/k8s/overlays/prod/kustomization.yaml.mustache index 204c52e4..13999b2f 100644 --- a/deploy/k8s/overlays/prod/kustomization.yaml.mustache +++ b/deploy/k8s/overlays/prod/kustomization.yaml.mustache @@ -1,11 +1,11 @@ resources: - "../../ingress" - - "../../web" + - "../../app" - "../../backend" images: -- name: web - newName: {{region_key}}.ocir.io/{{{tenancy_namespace}}}/{{{project_name}}}/web +- name: app + newName: {{region_key}}.ocir.io/{{{tenancy_namespace}}}/{{{project_name}}}/app newTag: {{{web_version}}} - name: backend newName: {{region_key}}.ocir.io/{{{tenancy_namespace}}}/{{{project_name}}}/backend diff --git a/deploy/terraform/.terraform.lock.hcl b/deploy/terraform/.terraform.lock.hcl index 8301e611..396723e4 100644 --- a/deploy/terraform/.terraform.lock.hcl +++ b/deploy/terraform/.terraform.lock.hcl @@ -22,22 +22,22 @@ provider "registry.terraform.io/hashicorp/cloudinit" { } provider "registry.terraform.io/hashicorp/helm" { - version = "2.14.0" + version = "2.14.1" constraints = ">= 2.9.0" hashes = [ - "h1:8Vt9264v3UE6mHLRG8yiteVl5h8ZSTkJXf1xdVLa7GA=", - "zh:087a475fda3649e4b6b9aeb5f21704972f5d85c10d0bf334289b0a1b8c1a5575", - "zh:1877991d976491d4e2a653a89491bd3b92123a00f442f15aa62caea8902677c7", - "zh:233d9e550b900be8bbf62871322964239bb4827b3500b77d7e2652a8bae6a106", - "zh:6ed09d405ade276dfc6ec591d113ca328ea3fe423405d4bc1116f7a06dfd86ec", - "zh:9039de4cbee5ae006d9cbf27f40f0a285feb02c3b00901535a1112853de55b5f", - "zh:aea6311b0f29edddefa21b8c7953314459caeace77d72d60588d1277f1723c54", - "zh:bd6a4fea3461c2751527f1c4e4c2c160e72f5b5a3b5cfbfe051adf61badd5ead", - "zh:c5f12a2ea4c3b62d9dd2d8f62c9918ef77b1f9dd4d6ccf1758a2a24139ab5319", - "zh:cd84d7258f263c3bd24138e7633b022451fdc1935a11e34932b63f71bbe6059f", - "zh:e637d01ee4dc2e5702d62c158399ab0d0ba3269e71f5db38db922ff05505ae2a", + "h1:JpDnPg+/pqynL54+Og9/bORTRYP1NxFjbrm65827Cns=", + "zh:0b8190016b101edbec158f869e14e5bcb9708dc88040e3d0119f6bf0a0384fa6", + "zh:0bd483d0193716ee7f30ce2e25eebb463aa51700c716842e25026bf2167e8feb", + "zh:5c8c16640f84f952e7ed1bab43b91c65f97168dd3bc189ea368e07fd40d44037", + "zh:67729452ff9c4f7a32d2e0008ce5deb86293929704ed3219971595db757924fa", + "zh:72dd1bc749de240e3700623ab1ff9b490ad5bbf17338e02d30b13a04a3b3c4ef", + "zh:7dcaec73d82c61f4bf315a5074217c6a8c1f774955a7b6f80c943a8907067a6f", + "zh:a48e27fbd17112e4f29d67d0467a8ea1ca554f98bf1f0748f1ebbc61355c465e", + "zh:b6283654f06d6ac5e0d67b0807c348fe5a700febf18f4990bf965705b379e29e", + "zh:dee35c1a536364431b9a6e022a9f89e2942425ca7111edd1ea89d596d68ee4e7", "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:fbf9c9936ae547b75a81170b7bd20f72bc5538e015efcf7d12f822358d758f57", + "zh:f5dd0141145104c681620d470093bd16bf3e4833021907581317c0b4ed650f8d", + "zh:f7fe46792e37d918e14740fb562b92a6d1594d60a43cc6b944a23a32930a2b16", ] } diff --git a/scripts/kustom.mjs b/scripts/kustom.mjs index 08205bd6..463239a4 100644 --- a/scripts/kustom.mjs +++ b/scripts/kustom.mjs @@ -19,6 +19,7 @@ const namespace = config.get("namespace"); const regionName = config.get("regionName"); const regionKey = config.get("regionKey"); const webVersion = config.get("webVersion"); +const appVersion = config.get("appVersion"); const backendVersion = config.get("backendVersion"); const certFullchain = config.get("certFullchain"); const certPrivateKey = config.get("certPrivateKey"); @@ -71,6 +72,7 @@ async function createProdKustomization() { region_key: regionKey, tenancy_namespace: namespace, project_name: projectName, + app_version: appVersion, web_version: webVersion, backend_version: backendVersion, }); diff --git a/scripts/release.mjs b/scripts/release.mjs index 1df861aa..83a699c3 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -32,6 +32,9 @@ const pwdOutput = (await $`pwd`).stdout.trim(); await cd(`${pwdOutput}/web`); const webVersion = await getNpmVersion(); config.set("webVersion", webVersion); +await cd(`${pwdOutput}/app`); +const appVersion = await getNpmVersion(); +config.set("appVersion", appVersion); await cd(`${pwdOutput}/backend`); const backendVersion = await getVersionGradle(); config.set("backendVersion", backendVersion); @@ -51,6 +54,7 @@ config.set("ocir_user_token", ocir_user_token); await containerLogin(namespace, ocir_user, ocir_user_token, ocirUrl); await releaseWeb(); +await releaseApp(); await releaseBackend(); async function releaseWeb() { @@ -66,6 +70,19 @@ async function releaseWeb() { await cd(".."); } +async function releaseApp() { + const service = "app"; + await cd(service); + const imageName = `${projectName}/${service}`; + await buildImage(`localhost/${imageName}`, appVersion); + const localImage = `localhost/${imageName}:${appVersion}`; + const remoteImage = `${ocirUrl}/${namespace}/${imageName}:${appVersion}`; + await tagImage(localImage, remoteImage); + await pushImage(remoteImage); + console.log(`${chalk.green(remoteImage)} pushed`); + await cd(".."); +} + async function releaseBackend() { const service = "backend"; await cd(service);