Working basic Dockerfile

This commit is contained in:
Roberto Alsina 2024-06-28 17:16:20 -03:00
parent 9fb4d7cd04
commit d77abc7b17

View File

@ -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"]