Compare commits
2 Commits
ca637f8d3b
...
17706676d5
| Author | SHA1 | Date |
|---|---|---|
|
|
17706676d5 | |
|
|
1687efbc7e |
|
|
@ -1,5 +1,5 @@
|
|||
# Backend API - Multi-stage optimized build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Copy csproj files first for layer caching
|
||||
|
|
@ -9,15 +9,18 @@ COPY src/backend/Adapters/Driven/Persistence/*.csproj Adapters/Driven/Persistenc
|
|||
COPY src/backend/Adapters/Driving/Api/*.csproj Adapters/Driving/Api/
|
||||
COPY src/backend/Host/*.csproj Host/
|
||||
|
||||
# Restore dependencies
|
||||
RUN dotnet restore Host/Host.csproj
|
||||
# Restore dependencies for Alpine/musl
|
||||
RUN dotnet restore Host/Host.csproj -r linux-musl-x64
|
||||
|
||||
# Copy source and build
|
||||
COPY src/backend/ .
|
||||
RUN dotnet publish Host/Host.csproj -c Release -o /app --no-restore
|
||||
RUN dotnet publish Host/Host.csproj -c Release -o /app -r linux-musl-x64 --self-contained false
|
||||
|
||||
# Runtime image
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS runtime
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS runtime
|
||||
# Install ICU for SQL Server globalization support
|
||||
RUN apk add --no-cache icu-libs
|
||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||
WORKDIR /app
|
||||
COPY --from=build /app .
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ WORKDIR /app
|
|||
|
||||
# Copy package files for caching
|
||||
COPY src/frontend/package*.json ./
|
||||
RUN npm ci --silent
|
||||
RUN npm ci
|
||||
|
||||
# Copy source and build
|
||||
COPY src/frontend/ .
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ server {
|
|||
|
||||
# API proxy
|
||||
location /graphql {
|
||||
proxy_pass http://api:5000;
|
||||
proxy_pass http://student-api:5000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
|
|
@ -24,7 +24,7 @@ server {
|
|||
}
|
||||
|
||||
location /health {
|
||||
proxy_pass http://api:5000;
|
||||
proxy_pass http://student-api:5000;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
# Deploy script for k3s cluster
|
||||
# Run this on the k3s master node after pulling latest code
|
||||
|
||||
set -e
|
||||
|
||||
NAMESPACE="student-enrollment"
|
||||
PROJECT_DIR="/home/andres/student-enrollment"
|
||||
TAG=$(git -C "$PROJECT_DIR" rev-parse --short HEAD)
|
||||
|
||||
echo "=== Deploying commit $TAG to k3s ==="
|
||||
|
||||
cd "$PROJECT_DIR"
|
||||
git pull
|
||||
|
||||
echo "=== Building API image ==="
|
||||
sudo docker build -t student-api:$TAG -f deploy/docker/Dockerfile.api .
|
||||
|
||||
echo "=== Building Frontend image ==="
|
||||
sudo docker build -t student-frontend:$TAG -f deploy/docker/Dockerfile.frontend .
|
||||
|
||||
echo "=== Importing images to k3s ==="
|
||||
sudo docker save student-api:$TAG | sudo k3s ctr images import -
|
||||
sudo docker save student-frontend:$TAG | sudo k3s ctr images import -
|
||||
|
||||
echo "=== Updating deployments ==="
|
||||
sudo kubectl -n $NAMESPACE set image deployment/student-api api=student-api:$TAG
|
||||
sudo kubectl -n $NAMESPACE set image deployment/student-frontend frontend=student-frontend:$TAG
|
||||
|
||||
echo "=== Waiting for rollout ==="
|
||||
sudo kubectl -n $NAMESPACE rollout status deployment/student-api --timeout=120s
|
||||
sudo kubectl -n $NAMESPACE rollout status deployment/student-frontend --timeout=60s
|
||||
|
||||
echo "=== Health check ==="
|
||||
sleep 5
|
||||
API_POD=$(sudo kubectl -n $NAMESPACE get pods -l app=student-api -o jsonpath='{.items[0].metadata.name}')
|
||||
sudo kubectl -n $NAMESPACE exec $API_POD -- wget -q --spider http://localhost:5000/health
|
||||
|
||||
echo "=== Deploy complete! Tag: $TAG ==="
|
||||
|
|
@ -12343,7 +12343,7 @@
|
|||
"version": "6.0.6",
|
||||
"resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-6.0.6.tgz",
|
||||
"integrity": "sha512-zgfER9s+ftkGKUZgc0xbx8T7/HMO4AV5/YuYiFc+AtgcO5T0v8AxYYNQ+ltzuzDZgNkYJaFspm5MMYLjQzrkmw==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
|
|
@ -12440,6 +12440,17 @@
|
|||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/hono": {
|
||||
"version": "4.11.3",
|
||||
"resolved": "https://registry.npmjs.org/hono/-/hono-4.11.3.tgz",
|
||||
"integrity": "sha512-PmQi306+M/ct/m5s66Hrg+adPnkD5jiO6IjA7WhWw0gSBSo1EcRegwuI1deZ+wd5pzCGynCcn2DprnE4/yEV4w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/hosted-git-info": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.2.tgz",
|
||||
|
|
@ -20114,7 +20125,7 @@
|
|||
"version": "8.19.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz",
|
||||
"integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue