Loading deploy.env.example→.env.prod.example +3 −0 Original line number Diff line number Diff line VITE_BASE_PATH= DOCKER_REGISTRY= K8S_NAMESPACE= .gitignore +2 −1 Original line number Diff line number Diff line node_modules/ dist .env deploy.env No newline at end of file .env.prod Dockerfile +2 −3 Original line number Diff line number Diff line FROM node:20.11.1 as build FROM node:20.11.1 AS build WORKDIR /app COPY package.json package-lock.json /app/ RUN npm ci COPY . /app/ ENV VITE_BASE_PATH=${VITE_BASE_PATH} RUN npm run build RUN npm run build-prod FROM bitnami/nginx:1.25.4 EXPOSE 8080 Loading deploy.sh +8 −6 Original line number Diff line number Diff line #!/bin/bash set -e SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}")) cd "$SCRIPT_DIR" set -o allexport source deploy.env source .env.prod set +o allexport docker build -t $DOCKER_REGISTRY --build-arg VITE_BASE_PATH=$VITE_BASE_PATH . && docker push $DOCKER_REGISTRY && # Scale down so pod gets recreated and uses new image oc --namespace stf218-app scale deploy -l app=exadigit-simulation-dashboard --replicas=0 docker build -t $DOCKER_REGISTRY:latest . # Get fully qualified image name DOCKER_IMAGE=$(docker inspect --format='{{index .RepoDigests 0}}' $DOCKER_REGISTRY:latest) docker push $DOCKER_REGISTRY:latest oc process -f ./deployment.yaml -o yaml --param=DASHBOARD_IMAGE="$DOCKER_REGISTRY" | oc apply -f - oc process -f ./deployment.yaml -o yaml --param=IMAGE="$DOCKER_IMAGE" --param=NAMESPACE="$K8S_NAMESPACE" | oc apply -f - deployment.yaml +50 −42 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Template apiVersion: template.openshift.io/v1 metadata: name: exadigit-simulation-server parameters: # - name: ENV # value: stage - name: NAMESPACE value: my-namespace - name: IMAGE objects: - apiVersion: apps/v1 kind: Deployment metadata: labels: app: exadigit-simulation-dashboard name: exadigit-simulation-dashboard namespace: stf218-app namespace: ${NAMESPACE} spec: replicas: 1 selector: Loading @@ -17,7 +28,7 @@ spec: app: exadigit-simulation-dashboard spec: containers: - image: ${DASHBOARD_IMAGE} - image: ${IMAGE} name: main imagePullPolicy: Always resources: Loading @@ -27,12 +38,11 @@ spec: limits: cpu: 100m memory: 250Mi --- - apiVersion: v1 kind: Service apiVersion: v1 metadata: name: exadigit-simulation-dashboard namespace: stf218-app namespace: ${NAMESPACE} labels: app: exadigit-simulation-dashboard spec: Loading @@ -44,5 +54,3 @@ spec: type: ClusterIP selector: app: exadigit-simulation-dashboard --- Loading
deploy.env.example→.env.prod.example +3 −0 Original line number Diff line number Diff line VITE_BASE_PATH= DOCKER_REGISTRY= K8S_NAMESPACE=
.gitignore +2 −1 Original line number Diff line number Diff line node_modules/ dist .env deploy.env No newline at end of file .env.prod
Dockerfile +2 −3 Original line number Diff line number Diff line FROM node:20.11.1 as build FROM node:20.11.1 AS build WORKDIR /app COPY package.json package-lock.json /app/ RUN npm ci COPY . /app/ ENV VITE_BASE_PATH=${VITE_BASE_PATH} RUN npm run build RUN npm run build-prod FROM bitnami/nginx:1.25.4 EXPOSE 8080 Loading
deploy.sh +8 −6 Original line number Diff line number Diff line #!/bin/bash set -e SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}")) cd "$SCRIPT_DIR" set -o allexport source deploy.env source .env.prod set +o allexport docker build -t $DOCKER_REGISTRY --build-arg VITE_BASE_PATH=$VITE_BASE_PATH . && docker push $DOCKER_REGISTRY && # Scale down so pod gets recreated and uses new image oc --namespace stf218-app scale deploy -l app=exadigit-simulation-dashboard --replicas=0 docker build -t $DOCKER_REGISTRY:latest . # Get fully qualified image name DOCKER_IMAGE=$(docker inspect --format='{{index .RepoDigests 0}}' $DOCKER_REGISTRY:latest) docker push $DOCKER_REGISTRY:latest oc process -f ./deployment.yaml -o yaml --param=DASHBOARD_IMAGE="$DOCKER_REGISTRY" | oc apply -f - oc process -f ./deployment.yaml -o yaml --param=IMAGE="$DOCKER_IMAGE" --param=NAMESPACE="$K8S_NAMESPACE" | oc apply -f -
deployment.yaml +50 −42 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Template apiVersion: template.openshift.io/v1 metadata: name: exadigit-simulation-server parameters: # - name: ENV # value: stage - name: NAMESPACE value: my-namespace - name: IMAGE objects: - apiVersion: apps/v1 kind: Deployment metadata: labels: app: exadigit-simulation-dashboard name: exadigit-simulation-dashboard namespace: stf218-app namespace: ${NAMESPACE} spec: replicas: 1 selector: Loading @@ -17,7 +28,7 @@ spec: app: exadigit-simulation-dashboard spec: containers: - image: ${DASHBOARD_IMAGE} - image: ${IMAGE} name: main imagePullPolicy: Always resources: Loading @@ -27,12 +38,11 @@ spec: limits: cpu: 100m memory: 250Mi --- - apiVersion: v1 kind: Service apiVersion: v1 metadata: name: exadigit-simulation-dashboard namespace: stf218-app namespace: ${NAMESPACE} labels: app: exadigit-simulation-dashboard spec: Loading @@ -44,5 +54,3 @@ spec: type: ClusterIP selector: app: exadigit-simulation-dashboard ---