refactor: reduce docker image size

This commit is contained in:
Juan Rodriguez
2024-07-12 22:53:48 +02:00
parent 36a06ac670
commit 115bbf7366
4 changed files with 66 additions and 64 deletions
+19 -9
View File
@@ -1,5 +1,6 @@
FROM alpine:edge as base
FROM alpine:edge AS build
ENV ENV=production
WORKDIR /usr/src/app
RUN apk update && apk add --no-cache \
@@ -9,20 +10,29 @@ RUN apk update && apk add --no-cache \
sqlite-dev \
openssl-dev
FROM base AS build
ENV ENV=production
COPY . .
COPY . .
RUN shards install
RUN shards build --progress
RUN shards build --release --no-debug
FROM alpine:edge AS runtime
ENV ENV=production
WORKDIR /usr/src/app
RUN apk add --no-cache \
gc \
pcre2 \
libevent \
yaml \
sqlite-libs \
openssl
RUN mkdir -p sqlite
FROM base AS release
RUN mkdir -p /usr/src/app/sqlite
COPY --from=build /usr/src/app/db db
COPY --from=build /usr/src/app/data data
COPY --from=build /usr/src/app/bin /usr/local/bin
COPY --from=build /usr/src/app/data /usr/local/data
EXPOSE 4000/tcp
CMD ["bit"]