Skip to content

Commit

Permalink
Dockerfile for python, python3, ruby, and C# template should not use …
Browse files Browse the repository at this point in the history
…ROOT

Signed-off-by: Eric Stoekl <ems5311@gmail.com>
  • Loading branch information
ericstoekl committed Nov 4, 2017
1 parent 2f5d5d8 commit c94b058
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
15 changes: 10 additions & 5 deletions template/csharp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

# Optimize for Docker builder caching by adding projects first.

RUN mkdir -p /root/src/function
WORKDIR /root/src/function
RUN mkdir -p /home/app/src/function
WORKDIR /home/app/src/function
COPY ./function/Function.csproj .

WORKDIR /root/src/
WORKDIR /home/app/src
COPY ./root.csproj .

RUN dotnet restore ./root.csproj

COPY . .

RUN dotnet publish -c release -o published

FROM microsoft/dotnet:2.0-runtime
RUN useradd app

#ADD https://github.com/openfaas/faas/releases/download/0.6.1/fwatchdog /usr/bin
RUN apt-get update -qy \
Expand All @@ -28,8 +30,11 @@ RUN apt-get update -qy \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /root/
COPY --from=builder /root/src/published .
WORKDIR /home/app/
COPY --from=builder /home/app/src/published .

RUN chown -R app ./
USER app

ENV fprocess="dotnet ./root.dll"
EXPOSE 8080
Expand Down
2 changes: 0 additions & 2 deletions template/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ RUN apk --no-cache add curl \
&& chmod +x /usr/bin/fwatchdog \
&& apk del curl --no-cache

WORKDIR /root/

# Turn down the verbosity to default level.
ENV NPM_CONFIG_LOGLEVEL warn

Expand Down
17 changes: 12 additions & 5 deletions template/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
FROM python:2.7-alpine

RUN adduser app -D

# Alternatively use ADD https:// (which will not be cached by Docker builder)
RUN apk --no-cache add curl \
&& echo "Pulling watchdog binary from Github." \
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.6.1/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog \
&& apk del curl --no-cache

WORKDIR /root/
RUN mkdir -p /home/app/function

COPY index.py /home/app
COPY requirements.txt /home/app

COPY index.py .
COPY requirements.txt .
WORKDIR /home/app
RUN pip install -r requirements.txt

COPY function function

RUN touch ./function/__init__.py

WORKDIR /root/function/
WORKDIR /home/app/function/
COPY function/requirements.txt .
RUN pip install -r requirements.txt

WORKDIR /root/
WORKDIR /home/app

RUN chown -R app ./
USER app

ENV fprocess="python index.py"

Expand Down
12 changes: 9 additions & 3 deletions template/python3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM python:3-alpine

RUN adduser app -D

# Alternatively use ADD https:// (which will not be cached by Docker builder)
RUN apk --no-cache add curl \
&& echo "Pulling watchdog binary from Github." \
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.6.5/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog \
&& apk del curl --no-cache

WORKDIR /root/
WORKDIR /home/app

COPY index.py .
COPY requirements.txt .
Expand All @@ -17,11 +19,15 @@ COPY function function

RUN touch ./function/__init__.py

WORKDIR /root/function/
WORKDIR /home/app/function/

COPY function/requirements.txt .
RUN pip install -r requirements.txt

WORKDIR /root/
WORKDIR /home/app

RUN chown -R app ./
USER app

ENV fprocess="python3 index.py"

Expand Down
13 changes: 10 additions & 3 deletions template/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
FROM ruby:2.4-alpine3.6

RUN adduser app -D

# Alternatively use ADD https:// (which will not be cached by Docker builder)
RUN apk --no-cache add curl \
&& echo "Pulling watchdog binary from Github." \
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.6.1/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog \
&& apk del curl --no-cache

WORKDIR /root/
RUN mkdir -p /home/app/
WORKDIR /home/app/

COPY Gemfile .
COPY index.rb .
COPY function function
RUN bundle install

WORKDIR /root/function/
WORKDIR /home/app/function/
RUN bundle install

WORKDIR /root/
WORKDIR /home/app/

RUN chown -R app ./
USER app

ENV fprocess="ruby index.rb"
HEALTHCHECK --interval=2s CMD [ -e /tmp/.lock ] || exit 1

Expand Down

0 comments on commit c94b058

Please sign in to comment.