File tree Expand file tree Collapse file tree 5 files changed +31
-13
lines changed Expand file tree Collapse file tree 5 files changed +31
-13
lines changed Original file line number Diff line number Diff line change 11FROM ghcr.io/openfaas/of-watchdog:0.9.3 as watchdog
2- FROM python:2.7-alpine
2+ FROM python:2.7-alpine as builder
33
44COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
55RUN chmod +x /usr/bin/fwatchdog
@@ -21,21 +21,23 @@ WORKDIR /home/app/
2121COPY --chown=app:app index.py .
2222COPY --chown=app:app requirements.txt .
2323USER root
24- RUN pip install -r requirements.txt
24+ RUN pip install --no-cache-dir - r requirements.txt
2525USER app
2626
2727RUN mkdir -p function
2828RUN touch ./function/__init__.py
2929WORKDIR /home/app/function/
3030COPY --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
3232
3333WORKDIR /home/app/
3434
3535USER root
3636COPY --chown=app:app function function
3737USER app
3838
39+ FROM builder as final
40+
3941ENV fprocess="python index.py"
4042ENV cgi_headers="true"
4143ENV mode="http"
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ RUN chmod +x /usr/bin/fwatchdog
77ARG ADDITIONAL_PACKAGE
88# Alternatively use ADD https:// (which will not be cached by Docker builder)
99
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/*
1113
1214# Add non root user
1315RUN addgroup --system app && adduser app --system --ingroup app
@@ -23,7 +25,7 @@ COPY --chown=app:app index.py .
2325COPY --chown=app:app requirements.txt .
2426
2527USER root
26- RUN pip install -r requirements.txt
28+ RUN pip install --no-cache-dir - r requirements.txt
2729
2830# Build the function directory and install any user-specified components
2931USER app
@@ -32,17 +34,20 @@ RUN mkdir -p function
3234RUN touch ./function/__init__.py
3335WORKDIR /home/app/function/
3436COPY --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
3638
3739# install function code
3840USER root
3941
4042COPY --chown=app:app function/ .
4143
44+ FROM builder as tester
4245ARG TEST_COMMAND=tox
4346ARG TEST_ENABLED=true
4447RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
4548
49+
50+ FROM builder as final
4651WORKDIR /home/app/
4752
4853# 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 .
2323COPY --chown=app:app requirements.txt .
2424
2525USER root
26- RUN pip install -r requirements.txt
26+ RUN pip install --no-cache-dir - r requirements.txt
2727
2828# Build the function directory and install any user-specified components
2929USER app
@@ -32,17 +32,20 @@ RUN mkdir -p function
3232RUN touch ./function/__init__.py
3333WORKDIR /home/app/function/
3434COPY --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
3636
3737# install function code
3838USER root
3939
4040COPY --chown=app:app function/ .
4141
42+
43+ FROM builder as tester
4244ARG TEST_COMMAND=tox
4345ARG TEST_ENABLED=true
4446RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
4547
48+ FROM builder as final
4649WORKDIR /home/app/
4750
4851# 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
77ARG ADDITIONAL_PACKAGE
88# Alternatively use ADD https:// (which will not be cached by Docker builder)
99
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/*
1113
1214# Add non root user
1315RUN addgroup --system app && adduser app --system --ingroup app
@@ -22,22 +24,26 @@ WORKDIR /home/app/
2224COPY --chown=app:app index.py .
2325COPY --chown=app:app requirements.txt .
2426USER root
25- RUN pip install -r requirements.txt
27+ RUN pip install --no-cache-dir - r requirements.txt
2628USER app
2729
2830RUN mkdir -p function
2931RUN touch ./function/__init__.py
3032WORKDIR /home/app/function/
3133COPY --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
3335
3436USER root
3537COPY --chown=app:app function/ .
3638
39+ FROM builder as tester
40+
3741ARG TEST_COMMAND=tox
3842ARG TEST_ENABLED=true
3943RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
4044
45+
46+ FROM builder as final
4147WORKDIR /home/app/
4248
4349USER app
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ WORKDIR /home/app/
2222COPY --chown=app:app index.py .
2323COPY --chown=app:app requirements.txt .
2424USER root
25- RUN pip install -r requirements.txt
25+ RUN pip install --no-cache-dir - r requirements.txt
2626
2727# Build the function directory and install any user-specified components
2828USER app
@@ -31,16 +31,18 @@ RUN mkdir -p function
3131RUN touch ./function/__init__.py
3232WORKDIR /home/app/function/
3333COPY --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
3535
3636# install function code
3737USER root
3838COPY --chown=app:app function/ .
3939
40+ FROM builder as tester
4041ARG TEST_COMMAND=tox
4142ARG TEST_ENABLED=true
4243RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"
4344
45+ FROM builder as final
4446WORKDIR /home/app/
4547
4648# configure WSGI server and healthcheck
You can’t perform that action at this time.
0 commit comments