File tree Expand file tree Collapse file tree 3 files changed +60
-18
lines changed Expand file tree Collapse file tree 3 files changed +60
-18
lines changed Original file line number Diff line number Diff line change @@ -8,20 +8,34 @@ ARG ADDITIONAL_PACKAGE
88# Alternatively use ADD https:// (which will not be cached by Docker builder)
99RUN apk --no-cache add ${ADDITIONAL_PACKAGE}
1010
11- WORKDIR /root/
11+ # Add non root user
12+ RUN addgroup -S app && adduser app -S -G app
13+ RUN chown app /home/app
1214
15+ USER app
16+
17+ ENV PATH=$PATH:/home/app/.local/bin
18+
19+ WORKDIR /home/app/
20+
21+ COPY index.py .
1322COPY requirements.txt .
23+ USER root
1424RUN pip install -r requirements.txt
15- COPY index.py .
25+ USER app
1626
1727RUN mkdir -p function
1828RUN touch ./function/__init__.py
19- WORKDIR /root /function/
29+ WORKDIR /home/app /function/
2030COPY function/requirements.txt .
21- RUN pip install -r requirements.txt
31+ RUN pip install --user -r requirements.txt
32+
33+ WORKDIR /home/app/
2234
23- WORKDIR /root/
24- COPY function function
35+ USER root
36+ COPY function function
37+ RUN chown -R app:app ./
38+ USER app
2539
2640ENV fprocess="python index.py"
2741ENV cgi_headers="true"
Original file line number Diff line number Diff line change @@ -9,20 +9,34 @@ RUN apk --no-cache add curl \
99
1010RUN apk --no-cache add musl-dev gcc make openssl-dev libffi-dev
1111
12- WORKDIR /root/
12+ # Add non root user
13+ RUN addgroup -S app && adduser app -S -G app
14+ RUN chown app /home/app
1315
16+ USER app
17+
18+ ENV PATH=$PATH:/home/app/.local/bin
19+
20+ WORKDIR /home/app/
21+
22+ COPY index.py .
1423COPY requirements.txt .
24+ USER root
1525RUN pip install -r requirements.txt
16- COPY index.py .
26+ USER app
1727
1828RUN mkdir -p function
1929RUN touch ./function/__init__.py
20- WORKDIR /root /function/
30+ WORKDIR /home/app /function/
2131COPY function/requirements.txt .
22- RUN pip install -r requirements.txt
32+ RUN pip install --user -r requirements.txt
33+
34+ WORKDIR /home/app/
2335
24- WORKDIR /root/
25- COPY function function
36+ USER root
37+ COPY function function
38+ RUN chown -R app:app ./
39+ USER app
2640
2741ENV fprocess="python index.py"
2842
Original file line number Diff line number Diff line change @@ -7,20 +7,34 @@ RUN chmod +x /usr/bin/fwatchdog
77ARG ADDITIONAL_PACKAGE
88RUN apk --no-cache add musl-dev gcc make ${ADDITIONAL_PACKAGE}
99
10- WORKDIR /root/
10+ # Add non root user
11+ RUN addgroup -S app && adduser app -S -G app
12+ RUN chown app /home/app
1113
14+ USER app
15+
16+ ENV PATH=$PATH:/home/app/.local/bin
17+
18+ WORKDIR /home/app/
19+
20+ COPY index.py .
1221COPY requirements.txt .
22+ USER root
1323RUN pip install -r requirements.txt
14- COPY index.py .
24+ USER app
1525
1626RUN mkdir -p function
1727RUN touch ./function/__init__.py
18- WORKDIR /root /function/
28+ WORKDIR /home/app /function/
1929COPY function/requirements.txt .
20- RUN pip install -r requirements.txt
30+ RUN pip install --user -r requirements.txt
31+
32+ WORKDIR /home/app/
2133
22- WORKDIR /root/
23- COPY function function
34+ USER root
35+ COPY function function
36+ RUN chown -R app:app ./
37+ USER app
2438
2539ENV fprocess="python index.py"
2640
You can’t perform that action at this time.
0 commit comments