Functions/template/crystal-http/Dockerfile

40 lines
1.1 KiB
Docker
Raw Normal View History

2023-06-02 21:18:46 +00:00
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
2023-06-04 00:09:25 +00:00
ARG ADDITIONAL_PACKAGE
2023-06-02 21:18:46 +00:00
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
2023-06-04 00:09:25 +00:00
RUN apk update && apk upgrade && apk add crystal shards openssl-dev ${ADDITIONAL_PACKAGE} && apk cache clean
2023-06-02 21:18:46 +00:00
WORKDIR /home/app
COPY function/shard.yml shard.yml
RUN shards install
COPY . .
2023-06-04 18:29:40 +00:00
RUN crystal build main.cr -o handler --error-trace -p && rm -rf /root/.cache
2023-06-02 21:18:46 +00:00
2023-06-04 00:09:25 +00:00
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
ARG ADDITIONAL_PACKAGE
RUN apk update && apk upgrade && apk add openssl pcre2 libgcc gc libevent ${ADDITIONAL_PACKAGE} && apk cache clean
# Add non root user
# Add non root user
2023-06-02 21:18:46 +00:00
RUN addgroup -S app && adduser app -S -G app
2023-06-04 00:09:25 +00:00
WORKDIR /home/app
2023-06-02 21:18:46 +00:00
USER app
2023-06-04 00:09:25 +00:00
COPY --from=build /home/app/function/ .
COPY --from=build /home/app/handler .
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
2023-06-02 21:18:46 +00:00
ENV fprocess="./handler"
2023-06-04 14:54:22 +00:00
ENV exec_timeout=30
2023-06-02 21:18:46 +00:00
EXPOSE 8080
HEALTHCHECK --interval=2s CMD [ -e /tmp/.lock ] || exit 1
ENV upstream_url="http://127.0.0.1:5000"
ENV mode="http"
CMD ["fwatchdog"]