From afd36146a57dbc92017c01177c753b07501a1d74 Mon Sep 17 00:00:00 2001 From: Kshitij Raj Sharma <36752999+kshitijrajsharma@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:42:27 +0200 Subject: [PATCH 1/2] Update api-requirements.txt --- backend/api-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/api-requirements.txt b/backend/api-requirements.txt index 380aa13b..17187cea 100644 --- a/backend/api-requirements.txt +++ b/backend/api-requirements.txt @@ -1,6 +1,6 @@ django==4.1.4 # gdal==3.6.2 -psycopg2==2.9.9 +psycopg2 djangorestframework==3.14.0 djangorestframework-gis==1.0 dj-database-url==1.2.0 From 9a1fefa08c914a3bb3edf17b46a154760bf3585f Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Mon, 30 Sep 2024 21:42:56 +0200 Subject: [PATCH 2/2] added git workflow and fixed dockerfile --- .github/workflows/docker_build.yml | 81 ++++++++++++++++++++++++++++++ backend/Dockerfile | 8 +-- backend/Dockerfile_CPU | 5 +- 3 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/docker_build.yml diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml new file mode 100644 index 00000000..ff967f03 --- /dev/null +++ b/.github/workflows/docker_build.yml @@ -0,0 +1,81 @@ +name: Build Docker Images for backend + +on: + push: + branches: + - master + paths: + - "backend/**" + - ".github/workflows/docker_build.yml" + pull_request: + branches: + - master + paths: + - "backend/**" + - ".github/workflows/docker_build.yml" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-api-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for API Docker + id: meta_api + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_api + + - name: Build and push API Docker image + uses: docker/build-push-action@v3 + with: + context: backend/ + file: backend/Dockerfile_CPU + push: false + tags: ${{ steps.meta_api.outputs.tags }} + labels: ${{ steps.meta_api.outputs.labels }} + + build-and-push-worker-image: + needs: build-and-push-api-image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Worker Docker + id: meta_worker + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_worker + + - name: Build and push Worker Docker image + uses: docker/build-push-action@v3 + with: + context: backend/ + file: backend/Dockerfile + push: false + tags: ${{ steps.meta_worker.outputs.tags }} + labels: ${{ steps.meta_worker.outputs.labels }} diff --git a/backend/Dockerfile b/backend/Dockerfile index 99137694..ca90a827 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -17,17 +17,17 @@ RUN pip install --global-option=build_ext --global-option="-I/usr/include/gdal" COPY docker/ramp/docker-requirements.txt /tmp/docker-requirements.txt RUN pip install -r /tmp/docker-requirements.txt - -RUN pip install --upgrade setuptools +# RUN pip install --upgrade pip +# RUN pip install --upgrade setuptools COPY requirements.txt /tmp/requirements.txt COPY api-requirements.txt /tmp/api-requirements.txt -RUN pip install -r /tmp/requirements.txt +RUN pip install --use-deprecated=legacy-resolver -r /tmp/requirements.txt COPY docker/ramp/solaris /tmp/solaris RUN pip install /tmp/solaris --use-feature=in-tree-build && \ pip install scikit-fmm --use-feature=in-tree-build - + WORKDIR /app COPY . /app diff --git a/backend/Dockerfile_CPU b/backend/Dockerfile_CPU index b6921403..164f9b3f 100644 --- a/backend/Dockerfile_CPU +++ b/backend/Dockerfile_CPU @@ -18,11 +18,12 @@ COPY docker/ramp/docker-requirements.txt /tmp/docker-requirements.txt RUN pip install -r /tmp/docker-requirements.txt -RUN pip install --upgrade setuptools +# RUN pip install --upgrade setuptools COPY requirements.txt /tmp/requirements.txt COPY api-requirements.txt /tmp/api-requirements.txt -RUN pip install -r /tmp/requirements.txt +# Don't use legacy resolver , TODO : fix this dependencies +RUN pip install --use-deprecated=legacy-resolver -r /tmp/requirements.txt COPY docker/ramp/solaris /tmp/solaris RUN pip install /tmp/solaris --use-feature=in-tree-build && \