Modernized build tooling
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
# Deployment Guide
|
||||
|
||||
## Docker
|
||||
|
||||
### Building the Image
|
||||
|
||||
```bash
|
||||
# Build with default tag
|
||||
docker build -t boilerplate:latest .
|
||||
|
||||
# Build with specific version
|
||||
docker build -t boilerplate:v0.1.0 .
|
||||
```
|
||||
|
||||
### Running the Container
|
||||
|
||||
```bash
|
||||
# Show help
|
||||
docker run --rm boilerplate:latest
|
||||
|
||||
# Run with custom arguments
|
||||
docker run --rm boilerplate:latest --name Docker --count 3
|
||||
```
|
||||
|
||||
### Multi-Platform Builds
|
||||
|
||||
```bash
|
||||
# Build for multiple platforms
|
||||
docker buildx build --platform linux/amd64,linux/arm64 \
|
||||
-t ghcr.io/cleverthis/boilerplate:latest \
|
||||
--push .
|
||||
```
|
||||
|
||||
## Kubernetes with Helm
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Kubernetes cluster (1.23+)
|
||||
- Helm 3.x installed
|
||||
- kubectl configured
|
||||
|
||||
### Basic Installation
|
||||
|
||||
```bash
|
||||
# Install with default values
|
||||
helm install boilerplate ./k8s
|
||||
|
||||
# Install with custom values
|
||||
helm install boilerplate ./k8s \
|
||||
--set image.tag=v0.1.0 \
|
||||
--set replicaCount=3
|
||||
```
|
||||
|
||||
### Customization
|
||||
|
||||
Create a `values-prod.yaml` file:
|
||||
|
||||
```yaml
|
||||
image:
|
||||
tag: v0.1.0
|
||||
pullPolicy: Always
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 200m
|
||||
memory: 256Mi
|
||||
|
||||
autoscaling:
|
||||
enabled: true
|
||||
minReplicas: 3
|
||||
maxReplicas: 10
|
||||
targetCPUUtilizationPercentage: 60
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
hosts:
|
||||
- host: api.example.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
tls:
|
||||
- secretName: api-tls
|
||||
hosts:
|
||||
- api.example.com
|
||||
```
|
||||
|
||||
Deploy with custom values:
|
||||
|
||||
```bash
|
||||
helm upgrade --install boilerplate ./k8s \
|
||||
-f values-prod.yaml \
|
||||
--namespace production \
|
||||
--create-namespace
|
||||
```
|
||||
|
||||
### Monitoring the Deployment
|
||||
|
||||
```bash
|
||||
# Check deployment status
|
||||
kubectl get deployments -n production
|
||||
|
||||
# Check pod status
|
||||
kubectl get pods -n production -l app.kubernetes.io/name=boilerplate
|
||||
|
||||
# Check HPA status
|
||||
kubectl get hpa -n production
|
||||
|
||||
# View logs
|
||||
kubectl logs -n production -l app.kubernetes.io/name=boilerplate
|
||||
```
|
||||
|
||||
### Rollback
|
||||
|
||||
```bash
|
||||
# View release history
|
||||
helm history boilerplate -n production
|
||||
|
||||
# Rollback to previous version
|
||||
helm rollback boilerplate -n production
|
||||
|
||||
# Rollback to specific revision
|
||||
helm rollback boilerplate 3 -n production
|
||||
```
|
||||
|
||||
## CI/CD Pipeline
|
||||
|
||||
The Forgejo Actions workflow automatically:
|
||||
|
||||
1. Runs linting and type checking
|
||||
2. Executes behavior tests on Python 3.11, 3.12, and 3.13
|
||||
3. Builds the wheel package
|
||||
4. Creates and tests the Docker image
|
||||
5. Validates the Helm chart
|
||||
|
||||
### Continuous Deployment
|
||||
|
||||
Add this job to `.forgejo/workflows/ci.yml` for automated deployments:
|
||||
|
||||
```yaml
|
||||
deploy:
|
||||
needs: [docker, helm]
|
||||
runs-on: docker
|
||||
if: github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy to Kubernetes
|
||||
env:
|
||||
KUBECONFIG_DATA: ${{ secrets.KUBECONFIG_BASE64 }}
|
||||
run: |
|
||||
echo "$KUBECONFIG_DATA" | base64 -d > /tmp/kubeconfig
|
||||
export KUBECONFIG=/tmp/kubeconfig
|
||||
|
||||
helm upgrade --install boilerplate ./k8s \
|
||||
--namespace production \
|
||||
--set image.tag=${{ github.sha }} \
|
||||
--wait
|
||||
```
|
||||
Reference in New Issue
Block a user