-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbf0bea
commit beaf33d
Showing
6 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |