From 414c07399f950e2a7d15aad512cc88997407d783 Mon Sep 17 00:00:00 2001 From: bboysoul Date: Thu, 13 Aug 2026 06:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfile=20+=20Gitea=20C?= =?UTF-8?q?I=EF=BC=88=E6=9E=84=E5=BB=BA=E9=95=9C=E5=83=8F=E2=86=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0yaml=E2=86=92ArgoCD=20sync=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 9 +++++ .gitea/workflows/ci.yaml | 77 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 22 ++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/ci.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ec1de0e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.git +.gitignore +.venv +__pycache__ +*.pyc +backend/*.db +frontend/node_modules +frontend/dist +backend/static diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..ae41122 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -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: bboysoulcn@gmail.com + 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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e9f148f --- /dev/null +++ b/Dockerfile @@ -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"]