diff --git a/Dockerfile b/Dockerfile index 2aa3da0c2..91404240d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ # Use an official Node runtime as the base image -FROM node:18 -ARG GIT_COMMIT=unknown -ENV GIT_COMMIT=$GIT_COMMIT +FROM node:18 AS base -# Install Nginx, Supervisor, Git, jq, curl, and Node Exporter dependencies +# Create dependency layer +FROM base AS dependencies RUN apt-get update && apt-get install -y \ nginx \ supervisor \ @@ -11,15 +10,21 @@ RUN apt-get update && apt-get install -y \ curl \ jq \ wget \ + apache2-utils \ && rm -rf /var/lib/apt/lists/* -# Install cloudflared RUN curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb > cloudflared.deb \ && dpkg -i cloudflared.deb \ && rm cloudflared.deb -# Install apache2-utils -RUN apt-get update && apt-get install -y apache2-utils +# Final image +FROM base + +# Copy installed packages from dependencies stage +COPY --from=dependencies / / + +ARG GIT_COMMIT=unknown +ENV GIT_COMMIT=$GIT_COMMIT # Set the working directory in the container WORKDIR /usr/src/app @@ -39,7 +44,7 @@ COPY . . RUN npm run build-prod # So we can see which commit was used to build the container -# openfront.io/commit.txt +# https://openfront.io/commit.txt RUN echo $GIT_COMMIT > static/commit.txt # Copy Nginx configuration and ensure it's used instead of the default