-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (36 loc) · 975 Bytes
/
Dockerfile
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
FROM --platform=linux/amd64 ubuntu:jammy AS base
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
libprotobuf-dev \
protobuf-compiler \
python3-pip \
python3-venv \
python3-grpcio \
curl \
&& rm -rf /var/lib/apt/lists/*
FROM base AS builder
WORKDIR /app
USER $USER_UID:$USER_GID
RUN python3 -m venv /home/$USERNAME/.venv
ENV PATH="/home/$USERNAME/.venv/bin:$PATH"
COPY requirements.txt requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt
USER 0
# Copy the source code
WORKDIR /app
COPY run_server.py run_server.py
RUN chown -R $USER_UID:$USER_GID /app/run_server.py
FROM builder AS runtime
EXPOSE 28080
WORKDIR /app
USER $USER_UID:$USER_GID
# Run the server
CMD ["python3", "run_server.py"]