Skip to content

Commit

Permalink
Deploy/testing (#1)
Browse files Browse the repository at this point in the history
* fixed pip install

* Update Dockerfile

* fixed installs

* dockerfile hotfix

* cache dir for pip

* Update Dockerfile

* pip dirs

* changed tmp dir

* free space action

* fixed reg credentials

* copy files inside the image

* fixed cache dir

* fixed issues

* cache purge

* pip update

* fixed build path

* fixed torch version

* fixed fairseq version

* dependency fix

* fixed dockerfile

* public registry push

* small bug fixes

* registry name fix

* fixed ingress tls

* fixed registry name

* fixed env position
  • Loading branch information
samirsalman authored Jun 20, 2024
1 parent 416af1f commit ce2f4fb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/production-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -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
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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} \
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"]
COPY data /FBK/server/data

COPY entrypoint.sh /FBK/

ENTRYPOINT bash /FBK/entrypoint.sh
2 changes: 1 addition & 1 deletion download_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 15 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 16 additions & 1 deletion kubernetes/production-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ce2f4fb

Please sign in to comment.