mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
improvement(runners): added blacksmith optimizations to workflows and dockerfiles to enhance performance (#2055)
* added blacksmith optimizations to workflows and dockerfiles to enhance performance. please review before pushing to production * remove cache from and cache to directives from docker based actions, per blacksmith docs --------- Co-authored-by: Connor Mulholland <connormul@Connors-MacBook-Pro.local>
This commit is contained in:
@@ -10,7 +10,7 @@ FROM base AS deps
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
|
||||
# Install turbo globally
|
||||
# Install turbo globally (cached separately, changes infrequently)
|
||||
RUN bun install -g turbo
|
||||
|
||||
COPY package.json bun.lock turbo.json ./
|
||||
@@ -18,16 +18,26 @@ RUN mkdir -p apps packages/db
|
||||
COPY apps/sim/package.json ./apps/sim/package.json
|
||||
COPY packages/db/package.json ./packages/db/package.json
|
||||
|
||||
# Install dependencies (this layer will be cached if package files don't change)
|
||||
RUN bun install --omit dev --ignore-scripts
|
||||
|
||||
# ========================================
|
||||
# Builder Stage: Build the Application
|
||||
# Builder Stage: Prepare source code
|
||||
# ========================================
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy node_modules from deps stage (cached if dependencies don't change)
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Copy package configuration files (needed for build)
|
||||
COPY package.json bun.lock turbo.json ./
|
||||
COPY apps/sim/package.json ./apps/sim/package.json
|
||||
COPY packages/db/package.json ./packages/db/package.json
|
||||
|
||||
# Copy source code (changes most frequently - placed last to maximize cache hits)
|
||||
COPY apps/sim ./apps/sim
|
||||
COPY packages ./packages
|
||||
|
||||
# ========================================
|
||||
# Runner Stage: Run the Socket Server
|
||||
@@ -37,16 +47,22 @@ WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Create non-root user and group
|
||||
# Create non-root user and group (cached separately)
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nextjs -u 1001
|
||||
|
||||
# Copy the sim app and the shared db package needed by socket-server
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/sim ./apps/sim
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/packages/db ./packages/db
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
||||
# Copy package.json first (changes less frequently)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
||||
|
||||
# Copy node_modules from builder (cached if dependencies don't change)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
||||
|
||||
# Copy db package (needed by socket-server)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/packages/db ./packages/db
|
||||
|
||||
# Copy sim app (changes most frequently - placed last)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/sim ./apps/sim
|
||||
|
||||
# Switch to non-root user
|
||||
USER nextjs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user