huathedev commited on
Commit
8cf1f74
·
1 Parent(s): 7dedbf6

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -0
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # temporary building stage
2
+ FROM python:3.8.5-slim as builder
3
+
4
+ # install system dependencies
5
+ RUN apt-get update
6
+ RUN apt-get install -y --no-install-recommends build-essential gcc
7
+ RUN apt-get install -y git
8
+
9
+ WORKDIR /usr/service
10
+
11
+ # create a virtual environment for python
12
+ RUN python -m venv /usr/service/venv
13
+ ENV PATH="/usr/service/venv/bin:$PATH"
14
+
15
+ # install python packages into virtual environment
16
+ COPY requirements.txt .
17
+ RUN pip install -r requirements.txt --no-cache-dir
18
+ RUN pip install pygco==0.0.16
19
+
20
+ # final stage
21
+ FROM python:3.8.5-slim@sha256:0e07cc072353e6b10de910d8acffa020a42467112ae6610aa90d6a3c56a74911
22
+
23
+ RUN apt-get update
24
+
25
+ # create a high-privileged user called "python"
26
+ RUN useradd -o -r -u 0 python
27
+
28
+ # make the service directory and give "python" user access rights to the directory
29
+ RUN mkdir /usr/service && chown python:python /usr/service
30
+ WORKDIR /usr/service
31
+
32
+ # copy python environment and source files to service directory, and give "python" user
33
+ # access rights to these files.
34
+ COPY --chown=python:python --from=builder /usr/service/venv venv
35
+ COPY --chown=python:python apps/demo apps/demo
36
+
37
+ # use the high-privileged "python" user
38
+ USER 0
39
+
40
+ # use python environment and start service
41
+ EXPOSE 8080
42
+ ENV PATH="/usr/service/venv/bin:$PATH"
43
+ ENV PYTHONPATH=.
44
+ CMD ["streamlit", "run", "apps/demo/ⓘ_Introduction.py", "--server.port", "8080"]