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
8
8
# Alternatively use ADD https:// (which will not be cached by Docker builder)
9
9
RUN apk --no-cache add ${ADDITIONAL_PACKAGE}
10
10
11
- WORKDIR /root/
11
+ # Add non root user
12
+ RUN addgroup -S app && adduser app -S -G app
13
+ RUN chown app /home/app
12
14
15
+ USER app
16
+
17
+ ENV PATH=$PATH:/home/app/.local/bin
18
+
19
+ WORKDIR /home/app/
20
+
21
+ COPY index.py .
13
22
COPY requirements.txt .
23
+ USER root
14
24
RUN pip install -r requirements.txt
15
- COPY index.py .
25
+ USER app
16
26
17
27
RUN mkdir -p function
18
28
RUN touch ./function/__init__.py
19
- WORKDIR /root /function/
29
+ WORKDIR /home/app /function/
20
30
COPY function/requirements.txt .
21
- RUN pip install -r requirements.txt
31
+ RUN pip install --user -r requirements.txt
32
+
33
+ WORKDIR /home/app/
22
34
23
- WORKDIR /root/
24
- COPY function function
35
+ USER root
36
+ COPY function function
37
+ RUN chown -R app:app ./
38
+ USER app
25
39
26
40
ENV fprocess="python index.py"
27
41
ENV cgi_headers="true"
Original file line number Diff line number Diff line change @@ -9,20 +9,34 @@ RUN apk --no-cache add curl \
9
9
10
10
RUN apk --no-cache add musl-dev gcc make openssl-dev libffi-dev
11
11
12
- WORKDIR /root/
12
+ # Add non root user
13
+ RUN addgroup -S app && adduser app -S -G app
14
+ RUN chown app /home/app
13
15
16
+ USER app
17
+
18
+ ENV PATH=$PATH:/home/app/.local/bin
19
+
20
+ WORKDIR /home/app/
21
+
22
+ COPY index.py .
14
23
COPY requirements.txt .
24
+ USER root
15
25
RUN pip install -r requirements.txt
16
- COPY index.py .
26
+ USER app
17
27
18
28
RUN mkdir -p function
19
29
RUN touch ./function/__init__.py
20
- WORKDIR /root /function/
30
+ WORKDIR /home/app /function/
21
31
COPY function/requirements.txt .
22
- RUN pip install -r requirements.txt
32
+ RUN pip install --user -r requirements.txt
33
+
34
+ WORKDIR /home/app/
23
35
24
- WORKDIR /root/
25
- COPY function function
36
+ USER root
37
+ COPY function function
38
+ RUN chown -R app:app ./
39
+ USER app
26
40
27
41
ENV fprocess="python index.py"
28
42
Original file line number Diff line number Diff line change @@ -7,20 +7,34 @@ RUN chmod +x /usr/bin/fwatchdog
7
7
ARG ADDITIONAL_PACKAGE
8
8
RUN apk --no-cache add musl-dev gcc make ${ADDITIONAL_PACKAGE}
9
9
10
- WORKDIR /root/
10
+ # Add non root user
11
+ RUN addgroup -S app && adduser app -S -G app
12
+ RUN chown app /home/app
11
13
14
+ USER app
15
+
16
+ ENV PATH=$PATH:/home/app/.local/bin
17
+
18
+ WORKDIR /home/app/
19
+
20
+ COPY index.py .
12
21
COPY requirements.txt .
22
+ USER root
13
23
RUN pip install -r requirements.txt
14
- COPY index.py .
24
+ USER app
15
25
16
26
RUN mkdir -p function
17
27
RUN touch ./function/__init__.py
18
- WORKDIR /root /function/
28
+ WORKDIR /home/app /function/
19
29
COPY function/requirements.txt .
20
- RUN pip install -r requirements.txt
30
+ RUN pip install --user -r requirements.txt
31
+
32
+ WORKDIR /home/app/
21
33
22
- WORKDIR /root/
23
- COPY function function
34
+ USER root
35
+ COPY function function
36
+ RUN chown -R app:app ./
37
+ USER app
24
38
25
39
ENV fprocess="python index.py"
26
40
You can’t perform that action at this time.
0 commit comments