Compare commits
No commits in common. "0e5a41c17091cf70d3b92bade641798d53ac3e7f" and "94ea99983ccdc9d91a63f59077c31f0189c2be65" have entirely different histories.
0e5a41c170
...
94ea99983c
@ -15,3 +15,7 @@ functions:
|
|||||||
lang: python3-flask
|
lang: python3-flask
|
||||||
handler: ./tapas
|
handler: ./tapas
|
||||||
image: ralsina/tapas:latest
|
image: ralsina/tapas:latest
|
||||||
|
tapas2:
|
||||||
|
lang: crystal
|
||||||
|
handler: ./tapas2
|
||||||
|
image: ralsina/tapas2:latest
|
||||||
|
7
tapas2/handler.cr
Normal file
7
tapas2/handler.cr
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require "json"
|
||||||
|
|
||||||
|
class Handler
|
||||||
|
def run(req : String)
|
||||||
|
return JSON::Any.new("Hello, Crystal. You said: #{req}")
|
||||||
|
end
|
||||||
|
end
|
7
tapas2/shard.yml
Normal file
7
tapas2/shard.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
name: crystal_faas_function
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
# dependencies:
|
||||||
|
# pg:
|
||||||
|
# github: will/crystal-pg
|
||||||
|
# version: "~> 0.5"
|
@ -1,29 +1,30 @@
|
|||||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
|
FROM crystallang/crystal:1.8.0 as builder
|
||||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
|
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install -y curl \
|
||||||
|
&& echo "Pulling watchdog binary from Github." \
|
||||||
|
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.9.6/fwatchdog > /usr/bin/fwatchdog \
|
||||||
|
&& chmod +x /usr/bin/fwatchdog
|
||||||
|
|
||||||
RUN apk update && apk upgrade
|
|
||||||
RUN apk add crystal shards
|
|
||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
COPY function/shard.yml shard.yml
|
COPY function/shard.yml shard.yml
|
||||||
RUN shards install
|
RUN shards install
|
||||||
RUN crystal build main.cr -o handler --release --static
|
RUN crystal build main.cr -o handler --release
|
||||||
RUN strip handler
|
|
||||||
|
FROM crystallang/crystal:1.8.0
|
||||||
|
RUN apt install ca-certificates
|
||||||
|
|
||||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
|
|
||||||
RUN apk update && apk upgrade
|
|
||||||
# Add non root user
|
# Add non root user
|
||||||
# Add non root user
|
RUN adduser app
|
||||||
RUN addgroup -S app && adduser app -S -G app
|
RUN mkdir -p /home/app
|
||||||
RUN chown app /home/app
|
|
||||||
|
|
||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
||||||
COPY --from=build /home/app/function/ .
|
COPY --from=builder /usr/bin/fwatchdog .
|
||||||
COPY --from=build /home/app/handler .
|
COPY --from=builder /home/app/function/ .
|
||||||
COPY --from=watchdog /fwatchdog /home/app/fwatchdog
|
COPY --from=builder /home/app/handler .
|
||||||
RUN chmod +x /home/app/fwatchdog
|
|
||||||
|
|
||||||
RUN chown -R app /home/app
|
RUN chown -R app /home/app
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user