Functions/template/crystal-http/Dockerfile

32 lines
742 B
Docker

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN apk update && apk upgrade && apk add crystal shards openssl-dev && apk cache clean
WORKDIR /home/app
COPY . .
COPY function/shard.yml shard.yml
RUN shards install
RUN crystal build main.cr -o handler --release && strip handler && rm -rf /root/.cache
# Create a non-root user
RUN addgroup -S app && adduser app -S -G app
USER app
WORKDIR /home/app
ENV fprocess="./handler"
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"]