-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
51 lines (34 loc) · 990 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
FROM python:3.10-slim
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install git && \
rm -rf /var/lib/apt/lists/*
ARG FROM_PATH=.
ARG USER=service-user
ARG HOME=/home/$USER
ARG TO_PATH=$HOME/service
ARG VIRTUAL_ENV=$TO_PATH/venv
# Create service directory
RUN mkdir -p $TO_PATH
WORKDIR $TO_PATH
# Create virtual environment
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip
# Copy necessary files
COPY $FROM_PATH/pyproject.toml pyproject.toml
COPY $FROM_PATH/.git .git
RUN mkdir ./tracker_dcs_web
RUN --mount=type=cache,target=$HOME/.cache/pip pip install .
# Copy service source code
COPY $FROM_PATH/tracker_dcs_web $TO_PATH/tracker_dcs_web
# service user
RUN /usr/sbin/useradd -m -u 5000 $USER
# prepare storage dir
RUN mkdir -p $TO_PATH/files
ENV STORAGE_DIR=/$TO_PATH/files
RUN chown -R $USER $STORAGE_DIR
RUN rm -rf /$TO_PATH/.git
# Create service user
USER $USER
ENV PYTHONPATH="$PWD:$PYTHONPATH"