Configure a Jenkins job builder to automate the build and deployment process.
Configuration File: build-config.yaml
Create a docker file for your application
File: Dockerfile
File: Jenkinsfile
Configure the Nginx to serve the application
File: nginx.conf
Create a helm chart for deployment
Files in the helm chart directory:
Chart.yaml
values.yaml
templates/Deployment.yaml
templates/Service.yaml
templates/Ingress.yaml
templates/subfilter-injection-configmap.yaml
Add the custom js injection config in the environment directory
Push these changes to the DevOps repository in the desired environment.
Trigger the Jenkins job manually or set it up to run automatically on every push to the repository.
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:
DevOps changes-
#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'
# 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
library 'ci-libs' buildPipeline(configFile: './build/build-config.yml')
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; } }
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
# 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
# deployment.yaml {{- template "common.deployment" . -}}
# service.yaml {{- template "common.service" . -}}
# ingress.yaml {{- template "common.ingress" . -}}
{{- $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 -}}
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> ';"