Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

366-sim-be-reduce-docker-image-by-sentence-transformers-python-package-size-optimization #367

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/backend_integration_tests_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Copy .env file
run: cp .env.example .env
Expand All @@ -48,10 +48,10 @@ jobs:
run: sed -i "s/<add_your_openai_api_key_here>/${OPENAIKEY}/g" .env

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
fi

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.12.4

Expand Down
19 changes: 12 additions & 7 deletions docker/Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
FROM python:3.12.2-slim AS base
FROM python:3.12.5-slim AS base

ARG path=/app

RUN mkdir $path
WORKDIR $path

ADD backend/protocol_rpc/requirements.txt backend/protocol_rpc/requirements.txt
RUN pip install --no-cache-dir -r backend/protocol_rpc/requirements.txt
RUN pip install --upgrade pip \
&& pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir -r backend/protocol_rpc/requirements.txt

RUN groupadd -r backend-group \
&& useradd -r -g backend-group backend-user \
&& mkdir -p /home/backend-user/.cache/huggingface \
&& chown -R backend-user:backend-group /home/backend-user \
&& chown -R backend-user:backend-group $path

ENV PYTHONPATH "${PYTHONPATH}:/${path}"
ENV FLASK_APP=backend/protocol_rpc/server.py
RUN groupadd -r backend-user && useradd -r -g backend-user backend-user \
&& chown -R backend-user:backend-user $path
ENV TRANSFORMERS_CACHE=/home/backend-user/.cache/huggingface

COPY ../.env .
COPY backend $path/backend
Expand All @@ -24,5 +29,5 @@ CMD watchmedo auto-restart --recursive --pattern="*.py" --ignore-patterns="*.pyc

###########START NEW IMAGE: PRODUCTION ###################
FROM base AS prod

USER backend-user
CMD flask run -h 0.0.0.0 -p ${FLASK_SERVER_PORT}
2 changes: 1 addition & 1 deletion docker/Dockerfile.database-migration
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12.2-slim
FROM python:3.12.5-slim

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.webrequest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 python:3.12-slim
FROM --platform=linux/amd64 python:3.12.5-slim

RUN apt-get update && \
apt-get install -y --no-install-recommends wget gnupg && \
Expand Down
Loading