forked from coracle/flotilla
eeacaca725
The Docker build wasn't making use of docker's cache because the .git directory was being copied into the build context. This means that even if the app did not change, if anything in git changed then docker would rebuild the entire app. This excludes the .git folder from the docker build, instead relying on the user to pass in the build hash at build time. Which is annoying but I don't think there's a better way around it. This was annoying me because I am deploying a self-hosted version of flotilla from a git branch via ansible and it was rebuilding flotilla every time. Co-authored-by: mplorentz <mplorentz@noreply.gitea.coracle.social> Reviewed-on: coracle/flotilla#88 Co-authored-by: Matt Lorentz <mplorentz@noreply.coracle.social> Co-committed-by: Matt Lorentz <mplorentz@noreply.coracle.social>
31 lines
690 B
Docker
31 lines
690 B
Docker
# Stage 1: Build
|
|
# Uses .env from build context for config (logo, branding, etc.)
|
|
# Optional: docker build --build-arg VITE_BUILD_HASH=$(git rev-parse --short HEAD) -t flotilla .
|
|
|
|
FROM node:20-bookworm AS builder
|
|
|
|
RUN npm install -g pnpm@latest
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm i
|
|
|
|
# Copy everything (including .env when present) - build.sh will source it
|
|
COPY . .
|
|
|
|
ARG VITE_BUILD_HASH
|
|
ENV VITE_BUILD_HASH=${VITE_BUILD_HASH}
|
|
|
|
ENV NODE_OPTIONS=--max_old_space_size=16384
|
|
RUN pnpm run build
|
|
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy only the built output - no source, no .env, no dev deps
|
|
COPY --from=builder /app/build ./build
|
|
|
|
CMD ["npx", "serve", "-s", "build"]
|