-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (59 loc) · 2.39 KB
/
Copy pathDockerfile
File metadata and controls
68 lines (59 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# docker build -t ai4-papi -f docker/Dockerfile .
FROM ubuntu:24.04
# Install Nomad
# Updated commands: https://developer.hashicorp.com/nomad/tutorials/get-started/gs-install
# curl, unzip: install for the rclone command
RUN apt-get update && \
apt-get install -y \
wget \
curl \
unzip \
gpg \
coreutils \
lsb-release \
pipx \
git \
micro \
gettext-base \
&& rm -rf /var/lib/apt/lists/*
RUN wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list
RUN apt-get update && \
apt-get install -y nomad && \
rm -rf /var/lib/apt/lists/*
# Install latest rclone (for checking backups in CVAT; "/storage" route)
RUN curl https://rclone.org/install.sh | bash
# Install API
# Starting in Ubuntu 24.04, virtual environments are mandatory so we use pipx
# * venv will be created at /root/.local/share/pipx/venvs/ai4papi
# * entrypoint will be located at /root/.local/bin/ai4papi-run
WORKDIR /home/ai4-papi
COPY . .
RUN pipx install -e .
# Add pipx-installed packages to path
RUN echo 'export PATH="/root/.local/bin:$PATH"' >> ~/.bashrc
# Add an envvar to notify PAPI that it should behave as in production
ENV IS_PROD=True
# Add Nomad configuration
ENV NOMAD_ADDR=https://193.146.75.205:4646
ENV NOMAD_CACERT=/home/nomad-certs/nomad-ca.pem
ENV NOMAD_CLIENT_CERT=/home/nomad-certs/cli.pem
ENV NOMAD_CLIENT_KEY=/home/nomad-certs/cli-key.pem
# We create a copy of the configuration so that we can run envsubst at launch time
# to add the ${DASHBOARD_URL} provided by TOSCA to the CORS section
RUN cp etc/main.yaml etc/main_tmp.yaml
# Run the API
EXPOSE 80
CMD \
# When deploying PAPI as a Nomad jobs, the `NOMAD_NAMESPACE` envvar is automatically
# created based on the namespace it fell on. But this clashes with the python-nomad
# configuration [1] that thinks you want to deploy new jobs always to that namespace.
# So we unset the envvar.
# [1]: https://python-nomad.readthedocs.io/en/latest/
unset NOMAD_NAMESPACE; \
# Replace ${DASHBOARD_URL} provided by TOSCA to the CORS section
envsubst < etc/main_tmp.yaml > etc/main.yaml; \
# Run PAPI
/root/.local/bin/ai4papi-run \
--host 0.0.0.0 \
--port 80