diff --git a/.github/workflows/production-deploy.yml b/.github/workflows/production-deploy.yml index ff4689c..ff9c028 100644 --- a/.github/workflows/production-deploy.yml +++ b/.github/workflows/production-deploy.yml @@ -26,17 +26,19 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 + aws-region: us-east-1 - name: Login to Amazon ECR id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - + uses: aws-actions/amazon-ecr-login@v2 + with: + registry-type: public + - name: build and deploy env: ENV: production SWARM_HOST: 156.54.237.240 - REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REGISTRY: public.ecr.aws/k2u7h0h2 AWS_REGION: eu-central-1 SWARM_PEM: ${{secrets.AI_PRODUCTION_PEM}} SHAREPOINT_ID: ${{secrets.SHAREPOINT_ID}} @@ -48,4 +50,10 @@ jobs: ssh-keyscan -p 2222 -H $SWARM_HOST >> ~/.ssh/known_hosts echo "ssh key added" echo "running deploy.sh $ENV" + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + echo "Free space:" + df -h sh deploy.sh $ENV diff --git a/Dockerfile b/Dockerfile index 62b92f0..0b3ff40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM nvidia/cuda:11.4.3-cudnn8-runtime-ubuntu20.04 ENV PYTHON_VERSION=3.9 +# this to prevent interactive intallation of 'ffmpeg' ENV DEBIAN_FRONTEND=noninteractive - RUN apt-get -qq update \ && apt-get -qq install --no-install-recommends \ python${PYTHON_VERSION} \ @@ -10,8 +10,9 @@ RUN apt-get -qq update \ python${PYTHON_VERSION}-dev build-essential \ locales \ ffmpeg \ - && rm -rf /var/lib/apt/lists/* && \ - ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 && \ + wget \ + && rm -rf /var/lib/apt/lists/* +RUN ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 && \ ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python && \ ln -s -f /usr/bin/pip3 /usr/bin/pip RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 @@ -32,8 +33,8 @@ ENV VIRTUAL_ENV=/opt/env/helsinki RUN python -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$ORIG_PATH" RUN pip install --no-cache-dir --upgrade pip -RUN pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 transformers sentencepiece --index-url https://download.pytorch.org/whl/cu118 - +RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 +RUN pip install --no-cache-dir transformers sentencepiece # Create app directory WORKDIR /FBK # Copy pipeline files @@ -45,8 +46,9 @@ RUN mkdir -p /FBK/SHAS COPY SHAS/. /FBK/SHAS ENV SHAS_ROOT=/FBK/SHAS # Copy http server files -RUN mkdir -p /FBK/server/data COPY CMD.httpserver_start.sh httpserver.py /FBK/server/ -COPY data/. /FBK/server/data -# run the command -ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file +COPY data /FBK/server/data + +COPY entrypoint.sh /FBK/ + +ENTRYPOINT bash /FBK/entrypoint.sh diff --git a/download_models.sh b/download_models.sh index 00223cb..f7a45b5 100644 --- a/download_models.sh +++ b/download_models.sh @@ -10,4 +10,4 @@ if [ ! -d "models/FBK_data_$VERSION" ]; then fi echo "FBK_data_$VERSION downloaded" -mv models/FBK_data_$VERSION/* root/.cache +mv models/FBK_data_$VERSION/* /root/.cache diff --git a/entrypoint.sh b/entrypoint.sh index 0752514..ec84960 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1 +1,15 @@ -bash download_models.sh && bash ./server/CMD.httpserver_start.sh +export VERSION=v1_2 + +cd /FBK +# download models if the directory doesn't contains the same version +if [ ! -d "models" ]; then + mkdir models +fi +if [ ! -d "models/FBK_data_$VERSION" ]; then + wget -O models/FBK_data_$VERSION.tar.gz https://fbk.sharepoint.com/:u:/s/MTUnit/$SHAREPOINT_ID?download=1 && tar xvfz models/FBK_data_$VERSION.tar.gz && rm models/FBK_data_$VERSION.tar.gz && mv FBK_data/.cache/* /root/.cache +fi +echo "FBK_data_$VERSION downloaded" +echo "Creating upload and out directories" +mkdir /FBK/server/upload mkdir /FBK/server/out +echo "Starting the server" +bash /FBK/server/CMD.httpserver_start.sh diff --git a/kubernetes/production-deployment.yaml b/kubernetes/production-deployment.yaml index 12b5855..f814a3b 100644 --- a/kubernetes/production-deployment.yaml +++ b/kubernetes/production-deployment.yaml @@ -29,9 +29,20 @@ spec: app: europeana-service spec: runtimeClassName: nvidia + restartPolicy: Always + + imagePullSecrets: + - name: europeana-regcred containers: - name: europeana-service - image: $IMAGE + env: + - name: SHAREPOINT_ID + valueFrom: + secretKeyRef: + name: europeana-service + key: SHAREPOINT_ID + imagePullPolicy: Always + image: "$IMAGE" ports: - containerPort: 8080 volumeMounts: @@ -76,6 +87,10 @@ metadata: namespace: ai-${ENV} spec: ingressClassName: contour + tls: + - hosts: + - europeana-service.translatedlabs.com + secretName: translatedlabs.com rules: - host: europeana-service.translatedlabs.com http: