Deployment Guide

Build and Deployment of vehicle-tracker

Jenkins Job Builder Configuration:

Configure a Jenkins job builder to automate the build and deployment process.

Configuration File: build-config.yaml

#Vehicle tracking web app - name: 'builds/SANITATION/vehicle-tracker' build: - work-dir: 'frontend/vehicle-tracker/map_web_app/route_map' image-name: 'vehicle-tracker' dockerfile: 'frontend/vehicle-tracker/map_web_app/docker/Dockerfile'

DockerFile And Jenkins Configuration:

Create a docker file for your application

File: Dockerfile

# Docker flutter tags https://hub.docker.com/r/cirrusci/flutter/tags?page=1&name=1.16 FROM ghcr.io/cirruslabs/flutter:3.10.3 AS build ARG WORK_DIR WORKDIR /app # copy the project files COPY ${WORK_DIR} . RUN flutter doctor RUN flutter pub get RUN flutter build web # Create runtime image FROM dwssio/nginx:mainline-alpine ENV WEB_DIR=/var/web/vehicle-tracker #RUN mkdir -p ${WEB_DIR} COPY --from=build /app/build/web/ ${WEB_DIR}/ COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf

File: Jenkinsfile

library 'ci-libs' buildPipeline(configFile: './build/build-config.yml')

Nginx Configuration:

Configure the Nginx to serve the application

File: nginx.conf

server { listen 80; underscores_in_headers on; server_tokens off; location /vehicle-tracker { root /var/web; index index.html index.htm; try_files $uri $uri/ /vehicle-tracker/index.html; } }

Helm Chart Configuration:

Create a helm chart for deployment

Files in the helm chart directory:

Chart.yaml

apiVersion: v2 name: vehicle-tracker description: A Helm chart for Kubernetes # A chart can be either an 'application' or a 'library' chart. # # Application charts are a collection of templates that can be packaged into versioned archives # to be deployed. # # Library charts provide useful utilities or functions for the chart developer. They're included as # a dependency of application charts to inject those utilities and functions into the rendering # pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. version: 0.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. appVersion: 1.16.0 dependencies: - name: common version: 0.0.5 repository: file://../../common

values.yaml

# Common Labels labels: app: "vehicle-tracker" group: "web" # Ingress Configs ingress: enabled: true context: "vehicle-tracker" namespace : egov # Init Containers Configs initContainers: {} # Container Configs image: repository: "vehicle-tracker" replicas: "1" httpPort: 80 healthChecks: enabled: true livenessProbePath: "/vehicle-tracker/" readinessProbePath: "/vehicle-tracker/" extraVolumes: | - name: js-injection configMap: name: vehicle-tracker-js-injection extraVolumeMounts: | - mountPath: /etc/nginx/conf.d/sub_filter.conf name: js-injection subPath: sub_filter.conf

templates/Deployment.yaml

# deployment.yaml {{- template "common.deployment" . -}}

templates/Service.yaml

# service.yaml {{- template "common.service" . -}}

templates/Ingress.yaml

# ingress.yaml {{- template "common.ingress" . -}}

templates/subfilter-injection-configmap.yaml

{{- $envOverrides := index .Values (tpl .Chart.Name .) -}} {{- $_ := set . "Values" (merge .Values $envOverrides) -}} {{- if index .Values "custom-js-injection" -}} apiVersion: v1 kind: ConfigMap metadata: name: {{ .Chart.Name }}-js-injection {{- if .Values.global.namespace }} namespace: {{ .Values.global.namespace }} {{- else }} namespace: {{ .Values.namespace }} {{- end }} data: {{- index .Values "custom-js-injection" | nindent 2 }} {{- end -}}

Add the custom js injection config in the environment directory

vehicle-tracker: custom-js-injection: | sub_filter.conf: " sub_filter '<head>' '<head> <script src=https://s3.ap-south-1.amazonaws.com/egov-dev-assets/globalConfigs.js type=text/javascript></script> ';"

Push these changes to the DevOps repository in the desired environment.

Run Jenkins Job:

Trigger the Jenkins job manually or set it up to run automatically on every push to the repository.

Build and Deploy:

Jenkins will build the application using the Dockerfile, and then deploy it using the Helm chart to the desired environment.

For any more information check this repository:

Repo changes- https://github.com/egovernments/SANITATION/blob/HLM-5602-vehicle-tracking-web/frontend/vehicle-tracker/map_web_app/docker/Dockerfile

DevOps changes-

https://github.com/egovernments/DIGIT-DevOps/tree/unified-env/deploy-as-code/helm/charts/sanitation/vehicle-tracker

Technology Stack:

Frontend: flutter : version: 3.10.5

Backend: java, spring boot

Last updated

All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.