File tree 5 files changed +31
-13
lines changed
5 files changed +31
-13
lines changed Original file line number Diff line number Diff line change 1
1
FROM ghcr.io/openfaas/of-watchdog:0.9.3 as watchdog
2
- FROM python:2.7-alpine
2
+ FROM python:2.7-alpine as builder
3
3
4
4
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
5
5
RUN chmod +x /usr/bin/fwatchdog
@@ -21,21 +21,23 @@ WORKDIR /home/app/
21
21
COPY --chown=app:app index.py .
22
22
COPY --chown=app:app requirements.txt .
23
23
USER root
24
- RUN pip install -r requirements.txt
24
+ RUN pip install --no-cache-dir - r requirements.txt
25
25
USER app
26
26
27
27
RUN mkdir -p function
28
28
RUN touch ./function/__init__.py
29
29
WORKDIR /home/app/function/
30
30
COPY --chown=app:app function/requirements.txt .
31
- RUN pip install --user -r requirements.txt
31
+ RUN pip install --no-cache-dir -- user -r requirements.txt
32
32
33
33
WORKDIR /home/app/
34
34
35
35
USER root
36
36
COPY --chown=app:app function function
37
37
USER app
38
38
39
+ FROM builder as final
40
+
39
41
ENV fprocess="python index.py"
40
42
ENV cgi_headers="true"
41
43
ENV mode="http"
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ RUN chmod +x /usr/bin/fwatchdog
7
7
ARG ADDITIONAL_PACKAGE
8
8
# Alternatively use ADD https:// (which will not be cached by Docker builder)
9
9
10
- RUN apt-get -qy update && apt-get -qy install gcc make ${ADDITIONAL_PACKAGE}
10
+ RUN apt-get -qy update \
11
+ && apt-get -qy install gcc make ${ADDITIONAL_PACKAGE} \
12
+ && rm -rf /var/lib/apt/lists/*
11
13
12
14
# Add non root user
13
15
RUN addgroup --system app && adduser app --system --ingroup app
@@ -23,7 +25,7 @@ COPY --chown=app:app index.py .
23
25
COPY --chown=app:app requirements.txt .
24
26
25
27
USER root
26
- RUN pip install -r requirements.txt
28
+ RUN pip install --no-cache-dir - r requirements.txt
27
29
28
30
# Build the function directory and install any user-specified components
29
31
USER app
@@ -32,17 +34,20 @@ RUN mkdir -p function
32
34
RUN touch ./function/__init__.py
33
35
WORKDIR /home/app/function/
34
36
COPY --chown=app:app function/requirements.txt .
35
- RUN pip install --user -r requirements.txt
37
+ RUN pip install --no-cache-dir -- user -r requirements.txt
36
38
37
39
# install function code
38
40
USER root
39
41
40
42
COPY --chown=app:app function/ .
41
43
44
+ FROM builder as tester
42
45
ARG TEST_COMMAND=tox
43
46
ARG TEST_ENABLED=true
44
47
RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
45
48
49
+
50
+ FROM builder as final
46
51
WORKDIR /home/app/
47
52
48
53
# configure WSGI server and healthcheck
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ COPY --chown=app:app index.py .
23
23
COPY --chown=app:app requirements.txt .
24
24
25
25
USER root
26
- RUN pip install -r requirements.txt
26
+ RUN pip install --no-cache-dir - r requirements.txt
27
27
28
28
# Build the function directory and install any user-specified components
29
29
USER app
@@ -32,17 +32,20 @@ RUN mkdir -p function
32
32
RUN touch ./function/__init__.py
33
33
WORKDIR /home/app/function/
34
34
COPY --chown=app:app function/requirements.txt .
35
- RUN pip install --user -r requirements.txt
35
+ RUN pip install --no-cache-dir -- user -r requirements.txt
36
36
37
37
# install function code
38
38
USER root
39
39
40
40
COPY --chown=app:app function/ .
41
41
42
+
43
+ FROM builder as tester
42
44
ARG TEST_COMMAND=tox
43
45
ARG TEST_ENABLED=true
44
46
RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
45
47
48
+ FROM builder as final
46
49
WORKDIR /home/app/
47
50
48
51
# configure WSGI server and healthcheck
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ RUN chmod +x /usr/bin/fwatchdog
7
7
ARG ADDITIONAL_PACKAGE
8
8
# Alternatively use ADD https:// (which will not be cached by Docker builder)
9
9
10
- RUN apt-get -qy update && apt-get -qy install ${ADDITIONAL_PACKAGE}
10
+ RUN apt-get -qy update \
11
+ && apt-get -qy install ${ADDITIONAL_PACKAGE} \
12
+ && rm -rf /var/lib/apt/lists/*
11
13
12
14
# Add non root user
13
15
RUN addgroup --system app && adduser app --system --ingroup app
@@ -22,22 +24,26 @@ WORKDIR /home/app/
22
24
COPY --chown=app:app index.py .
23
25
COPY --chown=app:app requirements.txt .
24
26
USER root
25
- RUN pip install -r requirements.txt
27
+ RUN pip install --no-cache-dir - r requirements.txt
26
28
USER app
27
29
28
30
RUN mkdir -p function
29
31
RUN touch ./function/__init__.py
30
32
WORKDIR /home/app/function/
31
33
COPY --chown=app:app function/requirements.txt .
32
- RUN pip install --user -r requirements.txt
34
+ RUN pip install --no-cache-dir -- user -r requirements.txt
33
35
34
36
USER root
35
37
COPY --chown=app:app function/ .
36
38
39
+ FROM builder as tester
40
+
37
41
ARG TEST_COMMAND=tox
38
42
ARG TEST_ENABLED=true
39
43
RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
40
44
45
+
46
+ FROM builder as final
41
47
WORKDIR /home/app/
42
48
43
49
USER app
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ WORKDIR /home/app/
22
22
COPY --chown=app:app index.py .
23
23
COPY --chown=app:app requirements.txt .
24
24
USER root
25
- RUN pip install -r requirements.txt
25
+ RUN pip install --no-cache-dir - r requirements.txt
26
26
27
27
# Build the function directory and install any user-specified components
28
28
USER app
@@ -31,16 +31,18 @@ RUN mkdir -p function
31
31
RUN touch ./function/__init__.py
32
32
WORKDIR /home/app/function/
33
33
COPY --chown=app:app function/requirements.txt .
34
- RUN pip install --user -r requirements.txt
34
+ RUN pip install --no-cache-dir -- user -r requirements.txt
35
35
36
36
# install function code
37
37
USER root
38
38
COPY --chown=app:app function/ .
39
39
40
+ FROM builder as tester
40
41
ARG TEST_COMMAND=tox
41
42
ARG TEST_ENABLED=true
42
43
RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
43
44
45
+ FROM builder as final
44
46
WORKDIR /home/app/
45
47
46
48
# configure WSGI server and healthcheck
You can’t perform that action at this time.
0 commit comments