2023-06-01 22:32:12 +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-01 21:52:39 +00:00
|
|
|
|
2023-06-01 23:11:40 +00:00
|
|
|
RUN apk update && apk upgrade
|
2023-06-01 22:32:12 +00:00
|
|
|
RUN apk add crystal shards
|
2023-06-02 20:21:10 +00:00
|
|
|
RUN apk cache clean
|
2023-06-01 21:52:39 +00:00
|
|
|
WORKDIR /home/app
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
COPY function/shard.yml shard.yml
|
|
|
|
RUN shards install
|
2023-06-01 22:32:12 +00:00
|
|
|
RUN crystal build main.cr -o handler --release --static
|
|
|
|
RUN strip handler
|
2023-06-01 21:52:39 +00:00
|
|
|
|
2023-06-01 22:32:12 +00:00
|
|
|
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
|
2023-06-02 20:21:10 +00:00
|
|
|
RUN apk update && apk upgrade && apk cache clean
|
2023-06-01 22:32:12 +00:00
|
|
|
# Add non root user
|
2023-06-01 21:52:39 +00:00
|
|
|
# Add non root user
|
2023-06-01 22:32:12 +00:00
|
|
|
RUN addgroup -S app && adduser app -S -G app
|
2023-06-01 21:52:39 +00:00
|
|
|
|
|
|
|
WORKDIR /home/app
|
2023-06-02 20:21:10 +00:00
|
|
|
USER app
|
2023-06-01 21:52:39 +00:00
|
|
|
|
2023-06-01 22:32:12 +00:00
|
|
|
COPY --from=build /home/app/function/ .
|
|
|
|
COPY --from=build /home/app/handler .
|
|
|
|
COPY --from=watchdog /fwatchdog /home/app/fwatchdog
|
2023-06-01 21:52:39 +00:00
|
|
|
|
|
|
|
ENV fprocess="./handler"
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=2s CMD [ -e /tmp/.lock ] || exit 1
|
|
|
|
|
|
|
|
CMD ["./fwatchdog"]
|