This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
.git
|
||||
.gitignore
|
||||
.venv
|
||||
__pycache__
|
||||
*.pyc
|
||||
backend/*.db
|
||||
frontend/node_modules
|
||||
frontend/dist
|
||||
backend/static
|
||||
@@ -0,0 +1,77 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
|
||||
env:
|
||||
APP_NAME: workout-five
|
||||
REGISTRY_URL: registry.bboysoul.cn
|
||||
REGISTRY_USER: bboysoul
|
||||
REGISTRY_PASSWORD: woyaoxuehuidocker
|
||||
IMAGE_NAME: registry.bboysoul.cn/workout-five
|
||||
GIT_EMAIL: [email protected]
|
||||
GIT_USER: bboysoul
|
||||
GIT_PASSWORD: Qk6zpSXnXu9YN8
|
||||
ARGOCD_USER: admin
|
||||
ARGOCD_PASS: hb7R9KPXGES45WtX
|
||||
ARGOCD_URL: argocd.bboysoul.cn
|
||||
YAML_REPO: git.bboysoul.cn/bboysoul/kubernetes-yaml
|
||||
YAML_PATH: kubernetes-yaml/aws-k8s/workout-five
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: docker
|
||||
container:
|
||||
options: --user=root
|
||||
steps:
|
||||
# Set up Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: https://github.com/docker/setup-buildx-action@v2
|
||||
# Login to registry
|
||||
- name: Login to Docker Registry
|
||||
uses: https://github.com/docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY_URL }}
|
||||
username: ${{ env.REGISTRY_USER }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
# Build and push
|
||||
- name: Build and push
|
||||
uses: https://github.com/docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
|
||||
# change images
|
||||
- name: update images
|
||||
run: |
|
||||
git config --global user.email "${{ env.GIT_EMAIL }}"
|
||||
git config --global user.name "${{ env.GIT_USER }}"
|
||||
git clone https://${{ env.GIT_USER }}:${{ env.GIT_PASSWORD }}@${{ env.YAML_REPO }}.git
|
||||
cd ${{ env.YAML_PATH }}
|
||||
kustomize edit set image ${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
git add .
|
||||
git commit -m "set image ${{ env.IMAGE_NAME }}:${{ github.sha }}"
|
||||
git push
|
||||
|
||||
- name: Install ArgoCD CLI
|
||||
run: |
|
||||
curl -sSL -o /usr/local/bin/argocd \
|
||||
https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
|
||||
chmod +x /usr/local/bin/argocd
|
||||
|
||||
- name: ArgoCD sync
|
||||
run: |
|
||||
argocd login ${{ env.ARGOCD_URL }} \
|
||||
--username ${{ env.ARGOCD_USER }} \
|
||||
--password ${{ env.ARGOCD_PASS }} \
|
||||
--insecure \
|
||||
--grpc-web
|
||||
argocd app sync aws-${{ env.APP_NAME }} --grpc-web
|
||||
argocd app wait aws-${{ env.APP_NAME }} \
|
||||
--health \
|
||||
--timeout 300 \
|
||||
--grpc-web
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
# Stage 1: Build Vue.js frontend
|
||||
FROM node:22-alpine AS frontend-builder
|
||||
WORKDIR /build
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Runtime
|
||||
FROM python:3.12-slim
|
||||
WORKDIR /app
|
||||
|
||||
COPY backend/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY backend/ .
|
||||
|
||||
# Copy built frontend (FastAPI serves as static)
|
||||
COPY --from=frontend-builder /build/dist/ /app/static/
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
Reference in New Issue
Block a user