Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump samples/versions - reduce image sizes through multi-stage builds #381

Merged
merged 1 commit into from Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 16 additions & 1 deletion docker-compose.extended.yml
Expand Up @@ -120,7 +120,7 @@ services:

# Pass a username as an argument to find how many images user has pushed to Docker Hub.
hubstats:
image: alexellis2/faas-dockerhubstats:latest
image: functions/hubstats:latest
labels:
function: "true"
depends_on:
Expand All @@ -131,6 +131,11 @@ services:
no_proxy: "gateway"
https_proxy: $https_proxy
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 20M
placement:
constraints:
- 'node.platform.os == linux'
Expand All @@ -148,6 +153,11 @@ services:
no_proxy: "gateway"
https_proxy: $https_proxy
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 20M
placement:
constraints:
- 'node.platform.os == linux'
Expand All @@ -166,6 +176,11 @@ services:
no_proxy: "gateway"
https_proxy: $https_proxy
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 20M
placement:
constraints:
- 'node.platform.os == linux'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -206,7 +206,7 @@ services:

# Converts body in (markdown format) -> (html)
markdown:
image: alexellis2/faas-markdownrender:latest
image: functions/markdown-render:latest
labels:
function: "true"
depends_on:
Expand Down
4 changes: 2 additions & 2 deletions sample-functions/AlpineFunction/Dockerfile
@@ -1,6 +1,6 @@
FROM alpine:latest
FROM alpine:3.6

ADD https://github.com/openfaas/faas/releases/download/0.6.5/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
# COPY ./fwatchdog /usr/bin/
RUN chmod +x /usr/bin/fwatchdog

Expand Down
2 changes: 1 addition & 1 deletion sample-functions/AlpineFunction/Dockerfile.arm64
@@ -1,6 +1,6 @@
FROM arm64v8/alpine:3.6

ADD https://github.com/alexellis/faas/releases/download/0.6.5/fwatchdog-arm64 /usr/bin/fwatchdog
ADD https://github.com/alexellis/faas/releases/download/0.6.9/fwatchdog-arm64 /usr/bin/fwatchdog
# COPY ./fwatchdog /usr/bin/
RUN chmod +x /usr/bin/fwatchdog

Expand Down
32 changes: 21 additions & 11 deletions sample-functions/ApiKeyProtected/Dockerfile
@@ -1,16 +1,26 @@
FROM alpine:latest
FROM golang:1.9.2-alpine as builder

WORKDIR /root/
MAINTAINER alex@openfaas.com
ENTRYPOINT []

EXPOSE 8080
ENV http_proxy ""
ENV https_proxy ""
RUN apk --no-cache add make curl \
&& curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog

ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin
# COPY fwatchdog /usr/bin/
RUN chmod +x /usr/bin/fwatchdog
WORKDIR /go/src/github.com/openfaas/faas/sample-functions/ApiKeyProtected

COPY app .
COPY handler.go .
# COPY vendor vendor

ENV fprocess="/root/app"
CMD ["fwatchdog"]
RUN go install

FROM alpine:3.6

# Needed to reach the hub
RUN apk --no-cache add ca-certificates

COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog
COPY --from=builder /go/bin/ApiKeyProtected /usr/bin/ApiKeyProtected
ENV fprocess "/usr/bin/ApiKeyProtected"

CMD ["/usr/bin/fwatchdog"]
9 changes: 0 additions & 9 deletions sample-functions/ApiKeyProtected/Dockerfile.build

This file was deleted.

12 changes: 0 additions & 12 deletions sample-functions/ApiKeyProtected/build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion sample-functions/BaseFunctions/dncore/Dockerfile
@@ -1,6 +1,6 @@
FROM microsoft/dotnet:sdk

ADD https://github.com/openfaas/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog

ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
Expand Down
2 changes: 1 addition & 1 deletion sample-functions/BaseFunctions/golang/Dockerfile
Expand Up @@ -8,7 +8,7 @@ COPY . /go/src/github.com/openfaas/faas/sample-functions/golang

RUN go install

ADD https://github.com/openfaas/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog

ENV fprocess "/go/bin/golang"
Expand Down
2 changes: 1 addition & 1 deletion sample-functions/BaseFunctions/golang/Dockerfile.win
Expand Up @@ -6,7 +6,7 @@ WORKDIR /go/src/github.com/openfaas/faas/sample-functions/golang
COPY . /go/src/github.com/openfaas/faas/sample-functions/golang
RUN go build

ADD ./watchdog.exe /
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog.exe /watchdog.exe

EXPOSE 8080
ENV fprocess="golang.exe"
Expand Down
4 changes: 2 additions & 2 deletions sample-functions/CaptainsIntent/Dockerfile
@@ -1,7 +1,7 @@
FROM alpine:latest
FROM alpine:3.6
RUN apk --update add nodejs nodejs-npm

ADD https://github.com/openfaas/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog

COPY package.json .
Expand Down
4 changes: 2 additions & 2 deletions sample-functions/ChangeColorIntent/Dockerfile
@@ -1,7 +1,7 @@
FROM alpine:latest
FROM alpine:3.6
RUN apk --update add nodejs nodejs-npm

ADD https://github.com/openfaas/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
#COPY ./fwatchdog /usr/bin/
RUN chmod +x /usr/bin/fwatchdog

Expand Down
27 changes: 18 additions & 9 deletions sample-functions/DockerHubStats/Dockerfile
@@ -1,17 +1,26 @@
FROM golang:1.7.5-alpine
MAINTAINER alexellis2@gmail.com
FROM golang:1.9.2-alpine as builder

MAINTAINER alex@openfaas.com
ENTRYPOINT []

RUN apk --no-cache add make
RUN apk --no-cache add make curl \
&& curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog

WORKDIR /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats

COPY . /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats

RUN make
RUN make install

ADD https://github.com/openfaas/faas/releases/download/0.6.0/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
FROM alpine:3.6

ENV fprocess "/go/bin/DockerHubStats"
HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1
# Needed to reach the hub
RUN apk --no-cache add ca-certificates

COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog
COPY --from=builder /go/bin/DockerHubStats /usr/bin/DockerHubStats
ENV fprocess "/usr/bin/DockerHubStats"

CMD [ "/usr/bin/fwatchdog"]
HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1
CMD ["/usr/bin/fwatchdog"]
24 changes: 16 additions & 8 deletions sample-functions/DockerHubStats/Dockerfile.armhf
@@ -1,17 +1,25 @@
FROM alexellis2/go-armhf:1.7.4
FROM golang:1.9.2-alpine as builder

MAINTAINER alexellis2@gmail.com
MAINTAINER alex@openfaas.com
ENTRYPOINT []

RUN apk --no-cache add make
RUN apk --no-cache add make curl \
&& curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog-armhf > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog

WORKDIR /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats

COPY . /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats

RUN make
RUN make install

FROM alpine:3.6

COPY ./fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
# Needed to reach the hub
RUN apk --no-cache add ca-certificates

ENV fprocess "/go/bin/DockerHubStats"
COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog
COPY --from=builder /go/bin/DockerHubStats /usr/bin/DockerHubStats
ENV fprocess "/usr/bin/DockerHubStats"

CMD [ "/usr/bin/fwatchdog"]
CMD ["/usr/bin/fwatchdog"]
6 changes: 1 addition & 5 deletions sample-functions/DockerHubStats/Makefile
@@ -1,9 +1,5 @@

.PHONY: install image
.PHONY: install

install:
@go install .

image:
@docker build -t alexellis2/dockerhub-stats .

3 changes: 0 additions & 3 deletions sample-functions/DockerHubStats/build.armhf.sh

This file was deleted.

4 changes: 0 additions & 4 deletions sample-functions/DockerHubStats/build.sh

This file was deleted.

4 changes: 2 additions & 2 deletions sample-functions/HostnameIntent/Dockerfile
@@ -1,7 +1,7 @@
FROM alpine:latest
FROM alpine:3.6
RUN apk --update add nodejs nodejs-npm

ADD https://github.com/openfaas/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog

COPY package.json .
Expand Down
32 changes: 21 additions & 11 deletions sample-functions/MarkdownRender/Dockerfile
@@ -1,16 +1,26 @@
FROM alpine:latest
FROM golang:1.9.2-alpine as builder

WORKDIR /root/
MAINTAINER alex@openfaas.com
ENTRYPOINT []

EXPOSE 8080
ENV http_proxy ""
ENV https_proxy ""
RUN apk --no-cache add make curl \
&& curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog

ADD https://github.com/openfaas/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
# COPY fwatchdog /usr/bin/
WORKDIR /go/src/github.com/openfaas/faas/sample-functions/MarkdownRender

COPY app .
COPY handler.go .
COPY vendor vendor

ENV fprocess="/root/app"
CMD ["fwatchdog"]
RUN go install

FROM alpine:3.6

# Needed to reach the hub
RUN apk --no-cache add ca-certificates

COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog
COPY --from=builder /go/bin/MarkdownRender /usr/bin/MarkdownRender
ENV fprocess "/usr/bin/MarkdownRender"

CMD ["/usr/bin/fwatchdog"]
17 changes: 0 additions & 17 deletions sample-functions/MarkdownRender/Dockerfile.armhf

This file was deleted.

10 changes: 0 additions & 10 deletions sample-functions/MarkdownRender/Dockerfile.build

This file was deleted.

11 changes: 0 additions & 11 deletions sample-functions/MarkdownRender/Dockerfile.build.armhf

This file was deleted.

33 changes: 33 additions & 0 deletions sample-functions/MarkdownRender/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.