From d77abc7b17f4206783589aaa08b3007eef793fb6 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Fri, 28 Jun 2024 17:16:20 -0300 Subject: [PATCH] Working basic Dockerfile --- templates/crystal/Dockerfile | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/templates/crystal/Dockerfile b/templates/crystal/Dockerfile index b51c87a..20a8453 100644 --- a/templates/crystal/Dockerfile +++ b/templates/crystal/Dockerfile @@ -1,35 +1,20 @@ FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build -RUN apk update && apk upgrade && apk add crystal shards openssl-dev && apk cache clean +RUN apk update && apk upgrade && apk add crystal shards openssl-dev zlib-dev && apk cache clean WORKDIR /home/app -COPY function/shard.yml shard.yml +COPY shard.yml *.cr . RUN shards install -COPY . . -RUN crystal build main.cr -o handler --error-trace -p && rm -rf /root/.cache +RUN shards build 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 +RUN apk update && apk upgrade && apk add openssl pcre2 libgcc gc libevent && apk cache clean RUN addgroup -S app && adduser app -S -G app WORKDIR /home/app USER app -COPY --from=build /home/app/function/ . -COPY --from=build /home/app/handler . -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog +COPY --from=build /home/app/bin/function . -ENV fprocess="./handler" -ENV exec_timeout=30 -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"] +CMD ["./function"]