diff --git a/Dockerfile b/Dockerfile index 2a9bb01..606a9e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/start.sh b/start.sh index 9389957..065e408 100644 --- a/start.sh +++ b/start.sh @@ -65,4 +65,6 @@ sudo -u cloudron -E /app/data/keila/bin/keila eval "Keila.Release.migrate()" echo "==> Starting Keila application" cd /app/data/keila +# Change the internal port since nginx listens on 4000 +export PORT="4001" exec sudo -u cloudron -E /app/data/keila/bin/keila start \ No newline at end of file