Use multi-stage build with pentacent/keila image

This commit is contained in:
Andreas Dueren
2025-06-20 08:02:49 -06:00
parent 2ae04de2fd
commit 09ad85510f
2 changed files with 15 additions and 21 deletions

View File

@ -1,32 +1,22 @@
FROM cloudron/base:4.2.0
# Install dependencies
RUN mkdir -p /app/code /app/data
WORKDIR /app/code
# Use Keila's prebuilt image as base for the release
FROM pentacent/keila:0.14 as keila-build
# Install Erlang and Elixir from Ubuntu repos
FROM cloudron/base:4.2.0
# Install runtime dependencies
RUN apt-get update \
&& apt-get install -y erlang elixir \
&& apt-get install -y git build-essential cmake nodejs npm postgresql-client \
&& apt-get install -y postgresql-client \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV MIX_ENV=prod
# Create directories
RUN mkdir -p /app/code /app/data
# Clone and build Keila
RUN git clone --depth 1 --branch v0.14.7 https://github.com/pentacent/keila.git . \
&& mix local.hex --force \
&& mix local.rebar --force \
&& mix deps.get --only prod \
&& mix deps.compile \
&& cd assets && npm ci && npm run deploy && cd .. \
&& mix phx.digest \
&& mix release
# Copy Keila from build stage
COPY --from=keila-build /opt/app /tmp/keila-release
# Copy initialization data
RUN cp -r _build/prod/rel/keila /tmp/keila-release
# Copy start script
# Copy configuration files
COPY start.sh /app/code/start.sh
COPY nginx.conf /etc/nginx/sites-available/default
@ -34,6 +24,8 @@ COPY nginx.conf /etc/nginx/sites-available/default
RUN chmod +x /app/code/start.sh \
&& chown -R cloudron:cloudron /app/code /app/data /tmp/keila-release
WORKDIR /app/code
EXPOSE 4000
CMD ["/app/code/start.sh"]