From 3932b298bf243d1dd63443f8d2d94e57e71387ca Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 20 Dec 2024 12:17:15 +0800 Subject: [PATCH] chore: refine Docker build process and update context paths - Updated GitHub Actions workflow to specify the Dockerfile location and set the build context to the root of the repository. - Modified Dockerfile to copy backend and other required modules from their respective directories, improving the build process. --- .github/workflows/docker-crawlab.yml | 3 ++- backend/Dockerfile | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-crawlab.yml b/.github/workflows/docker-crawlab.yml index c74ae702..28bb17a9 100644 --- a/.github/workflows/docker-crawlab.yml +++ b/.github/workflows/docker-crawlab.yml @@ -199,7 +199,8 @@ jobs: - name: Build and push image uses: docker/build-push-action@v5 with: - context: ${{ env.IMAGE_PATH_CRAWLAB_BACKEND }} + context: . + file: ${{ env.IMAGE_PATH_CRAWLAB_BACKEND }}/Dockerfile push: true tags: ${{ env.IMAGE_NAME_CRAWLAB_BACKEND }}:${{ needs.setup.outputs.version }} - name: Set output diff --git a/backend/Dockerfile b/backend/Dockerfile index 877f70a5..6fee1322 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,9 +1,18 @@ FROM golang:1.22.9 AS build +# Context path is the root of the repository + WORKDIR /go/src/app -# Copy all required modules from parent directory -COPY .. . +# Copy the current directory (backend) first +COPY ./backend ./backend/ + +# Copy required modules from relative paths +COPY ./core ./core/ +COPY ./db ./db/ +COPY ./grpc ./grpc/ +COPY ./trace ./trace/ +COPY ./vcs ./vcs/ ENV GO111MODULE on