Skip to content

Commit

Permalink
Merge pull request #25 from oracle-devrel/deploy-jet-instead-of-react
Browse files Browse the repository at this point in the history
swap react app for Oracle Jet app
  • Loading branch information
peppertech authored Aug 14, 2024
2 parents 09536a1 + 1edcdcd commit 6d9d62d
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 27 deletions.
7 changes: 4 additions & 3 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/
CMD ["nginx", "-g", "daemon off;"]
13 changes: 13 additions & 0 deletions deploy/k8s/app/app-svc.yaml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions deploy/k8s/app/app.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions deploy/k8s/app/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- app.yaml
- app-svc.yaml
namespace: backend
16 changes: 8 additions & 8 deletions deploy/k8s/ingress/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions deploy/k8s/overlays/prod/kustomization.yaml.mustache
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 13 additions & 13 deletions deploy/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions scripts/kustom.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
});
Expand Down
17 changes: 17 additions & 0 deletions scripts/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() {
Expand All @@ -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);
Expand Down

0 comments on commit 6d9d62d

Please sign in to comment.