adding devops

used gemini to create the k8s/dockerfiles faster
This commit is contained in:
Smigz 2025-05-02 16:47:07 +00:00
parent 5c09c5a22f
commit 6c14a968c3
74 changed files with 2061 additions and 16 deletions

38
todo/devops/Dockerfile Normal file
View file

@ -0,0 +1,38 @@
# Use an official Node.js runtime as the base image
FROM node:18-alpine as builder
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install any needed dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Use an official Nginx runtime as the base image
FROM nginx:stable-alpine
# Set the working directory in the container
WORKDIR /usr/share/nginx/html
# Remove default nginx static files
RUN rm -rf ./*
# Copy static files from the builder stage
COPY --from=builder /app/dist .
# Copy the nginx configuration file
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
# Command to run when starting the container
CMD ["nginx", "-g", "daemon off;"]

View file

@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo-deployment
spec:
replicas: 3
selector:
matchLabels:
app: todo
template:
metadata:
labels:
app: todo
spec:
containers:
- name: todo
image: ghcr.io/smiggiddy/odin-codeprojects/todo:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: todo-service
spec:
selector:
app: todo
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer