Last active
May 1, 2023 08:45
-
-
Save inyee786/2755de492d2510328327aa33d30b8b2e to your computer and use it in GitHub Desktop.
Deploy SPA on Kubernetes
This file contains hidden or 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
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend | |
FROM node:10.8.0 as build-stage | |
WORKDIR /app | |
COPY package*.json /app/ | |
RUN npm install | |
COPY ./ /app/ | |
ARG configuration=production | |
RUN npm run build -- --output-path=./dist/out --configuration $configuration | |
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx | |
FROM nginx:1.15 | |
#Copy ci-dashboard-dist | |
COPY --from=build-stage /app/dist/out/ /usr/share/nginx/html | |
#Copy default nginx configuration | |
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf |
This file contains hidden or 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
# Expires map | |
map $sent_http_content_type $expires { | |
default off; | |
text/html epoch; | |
text/css max; | |
application/json max; | |
application/javascript max; | |
~image/ max; | |
} | |
server { | |
listen 80; | |
location / { | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
try_files $uri $uri/ /index.html =404; | |
} | |
expires $expires; | |
gzip on; | |
} |
This file contains hidden or 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
apiVersion: apps/v1beta1 | |
kind: Deployment | |
metadata: | |
name: deployment-name | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
label-key : label-value | |
spec: | |
containers: | |
- name: deploment-container-name | |
image: docker-container-registry | |
imagePullPolicy: Always | |
ports: | |
- containerPort: 80 | |
This file contains hidden or 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
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
service-label-key: service-label-value | |
name: service-name | |
spec: | |
type: ClusterIP | |
ports: | |
- name: service-port-name | |
port: 80 | |
protocol: TCP | |
selector: | |
deployment-label-key: deployment-label-value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment