Skip to content

Commit

Permalink
feat: add helm charts
Browse files Browse the repository at this point in the history
  • Loading branch information
sujeet-agrahari committed Feb 14, 2024
1 parent dbf0bea commit beaf33d
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 4 deletions.
39 changes: 35 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,54 @@
FROM node:16-slim as base
# Use node base image with tag 16-slim
FROM node:18-slim as base

# Set NODE_ENV environment variable to production
ENV NODE_ENV=production

# Expose port 3000
EXPOSE 3000

# Install latest version of npm globally
RUN npm i npm@latest -g

# Create app directory and set permissions
RUN mkdir /app && chown -R node:node /app

# Set working directory and user
WORKDIR /app
USER node

# Copy package.json and package-lock.json
COPY --chown=node:node package.json package-lock*.json ./

# Install dependencies and clean npm cache
RUN npm install && npm cache clean --force

# Set PATH environment variable
ENV PATH /app/node_modules/.bin:$PATH
# check every 30s to ensure this service returns HTTP 200
# HEALTHCHECK --interval=30s CMD node healthcheck.jsc

# Healthcheck (optional: uncomment if needed)
# HEALTHCHECK --interval=30s CMD node healthcheck.js

# Stage for source code
FROM base as source

# Copy source code
COPY --chown=node:node . .

# Development stage
FROM source as dev

# Set NODE_ENV environment variable to development
ENV NODE_ENV=development

# Install development dependencies
RUN npm install --only=development

# Command to run development server
CMD ["npm", "run", "start:dev"]

# Production stage
FROM source as prod
CMD ["npm", "run", "start:prod"]

# Command to run production server
CMD ["npm", "run", "start:prod"]
Binary file added dbschema/mealmate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions quick-links-charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: quick-links-chart
description: A Helm chart for deploying quick-links service
version: 0.1.0
33 changes: 33 additions & 0 deletions quick-links-charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}-quick-links
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: quick-links
template:
metadata:
labels:
app: quick-links
spec:
containers:
- name: quick-links
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: DB_HOST
value: {{ .Values.env.DB_HOST }}
- name: DB_PORT
value: {{ .Values.env.DB_PORT }}
- name: DB_USER
value: {{ .Values.env.DB_USER }}
- name: DB_PASSWORD
value: {{ .Values.env.DB_PASSWORD }}
- name: DB_NAME
value: {{ .Values.env.DB_NAME }}
- name: REDIS_HOST
value: {{ .Values.env.REDIS_HOST }}
- name: REDIS_PASSWORD
value: {{ .Values.env.REDIS_PASSWORD }}
13 changes: 13 additions & 0 deletions quick-links-charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.service.name }}
spec:
selector:
app: quick-links
ports:
- name: quick-links
protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
type: {{ .Values.service.type }}
18 changes: 18 additions & 0 deletions quick-links-charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
replicaCount: 2
image:
repository: quick-links
tag: dev
pullPolicy: Never
env:
DB_HOST: 'postgres-postgresql-ha-pgpool'
DB_USER: 'postgres'
DB_PASSWORD: 'password'
DB_NAME: 'quicklink'
REDIS_HOST: 'redis-master'
REDIS_PASSWORD: 'Mx765t6kQe'
deployment:
name: quick-links-deployment
service:
name: quick-links-service
type: ClusterIP
port: 3000

0 comments on commit beaf33d

Please sign in to comment.