From ae8e92404546ef36584cea356daca90d7c5a8a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Thu, 16 Oct 2025 14:20:28 +0800 Subject: [PATCH] =?UTF-8?q?ci(docker):=20=E7=AE=80=E5=8C=96=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96docker=E6=9E=84=E5=BB=BA=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除不必要的环境文件拷贝步骤,更新Go安装方式 添加调试信息以帮助定位.env文件问题 --- .gitea/workflows/docker.yaml | 74 +++++++++++++----------------------- 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml index 9a7fc7f..aa62c8e 100644 --- a/.gitea/workflows/docker.yaml +++ b/.gitea/workflows/docker.yaml @@ -31,70 +31,50 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # 使用gitea-tool-cache需要指定具体的版本号 go: ["1.24.5"] steps: - name: Checkout uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/checkout@v4 - # 将.env环境变量配置文件拷贝致gitea runner容器 - - name: copy env file to runner container - uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/ssh-action@v0.1.10 - with: - host: ${{ env.SSH_HOST }} - username: ${{ env.SSH_USER }} - password: ${{ env.SSH_PASSWORD }} - port: ${{ env.SSH_PORT }} - debug: true - script: | - mkdir -p /install/cicd_env_files - cd /install/cicd_env_files - docker cp ${{env.JOB_CONTAINER_NAME}}:${{gitea.WORKSPACE}}/deploy/.env ./.env - source ./.env - docker cp ${{env.JOB_CONTAINER_NAME}}:${{gitea.WORKSPACE}}/docs/${SERVICE_NAME}.json . - docker cp .env ${{ vars.RUNNER_CONTAINER_NAME }}:/.env - docker exec ${{ vars.RUNNER_CONTAINER_NAME }} /bin/bash -c "source /.env" - - name: Install Go environment - uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/gitea-tool-cache@v5 - with: - # 需要指定具体版本号! - go-version: ${{ matrix.go }} - - - uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/setup-go@v2 + uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/setup-go@v4 with: go-version: ${{ matrix.go }} - - uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Prepare GO environment run: | - go env -w GOPROXY=https://goproxy.cn,direct + go env -w GOPROXY=https://goproxy.cn,direct go env -w GOPRIVATE="${{ vars.DOMAIN_OF_GITEA}}" - git config --global url."https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/".insteadOf "https://${{ vars.DOMAIN_OF_GITEA}}/" + git config --global url."https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/".insteadOf "https://${{ vars.DOMAIN_OF_GITEA}}/" - - name: Build and push docker image + - name: Debug filesystem and build docker image run: | - source ${{gitea.WORKSPACE}}/deploy/.env + echo "=== Debug Information ===" + echo "Current working directory: $(pwd)" + echo "Gitea workspace: ${{ gitea.workspace }}" + echo "Listing current directory:" + ls -la + echo "Checking if deploy directory exists:" + ls -la deploy/ || echo "deploy directory not found" + echo "Checking if .env file exists:" + ls -la deploy/.env || echo ".env file not found in deploy/" + echo "Trying to find .env files:" + find . -name ".env" -type f 2>/dev/null || echo "No .env files found" + echo "=========================" + + # Try to source the .env file with proper path + if [ -f "./deploy/.env" ]; then + echo "Found .env file, sourcing it..." + source ./deploy/.env + else + echo "ERROR: .env file not found at ./deploy/.env" + exit 1 + fi + go clean -modcache go mod tidy make build-linux make docker make publish-docker - make docker-run - - - name: Build APIDOC docker image - run: | - source ${{gitea.WORKSPACE}}/deploy/.env - echo ${SERVICE_NAME} - echo ${APIDOC_CONTAINER_NAME} - echo ${SWAGGER_JSON} - make swagger-docker \ No newline at end of file + make docker-run \ No newline at end of file