Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.

dockerfile

+55 -49
+55 -49
Dockerfile
··· 1 - # Production stage 2 - FROM oven/bun:1 AS build 1 + # Build stage 2 + FROM oven/bun:1.3 AS build 3 3 4 4 WORKDIR /app 5 5 6 6 # Copy workspace configuration 7 - COPY package.json package.json 8 - COPY bun.lock bun.lock 9 - COPY bunfig.toml bunfig.toml 10 - COPY tsconfig.json tsconfig.json 7 + COPY package.json bunfig.toml tsconfig.json bun.lock* ./ 11 8 12 9 # Copy all workspace package.json files first (for dependency resolution) 13 - COPY packages/@wisp/atproto-utils/package.json ./packages/@wisp/atproto-utils/package.json 14 - COPY packages/@wisp/constants/package.json ./packages/@wisp/constants/package.json 15 - COPY packages/@wisp/database/package.json ./packages/@wisp/database/package.json 16 - COPY packages/@wisp/fs-utils/package.json ./packages/@wisp/fs-utils/package.json 17 - COPY packages/@wisp/lexicons/package.json ./packages/@wisp/lexicons/package.json 18 - COPY packages/@wisp/observability/package.json ./packages/@wisp/observability/package.json 19 - COPY packages/@wisp/safe-fetch/package.json ./packages/@wisp/safe-fetch/package.json 10 + COPY cli ./cli 11 + COPY packages ./packages 20 12 COPY apps/main-app/package.json ./apps/main-app/package.json 21 13 COPY apps/hosting-service/package.json ./apps/hosting-service/package.json 22 14 23 - # Install dependencies 24 - RUN bun install 15 + # Install all dependencies (including workspaces) 16 + RUN bun install --frozen-lockfile 25 17 26 - # Copy workspace source files 27 - COPY packages ./packages 18 + # Copy source files 28 19 COPY apps/main-app ./apps/main-app 29 20 30 - ENV NODE_ENV=production 21 + # Build compiled server 22 + RUN bun build \ 23 + --compile \ 24 + --target bun \ 25 + --minify \ 26 + --outfile server \ 27 + apps/main-app/src/index.ts 31 28 32 - # Build Tailwind CSS (build to temp files then replace originals) 33 - RUN bunx @tailwindcss/cli -i ./apps/main-app/public/styles/global.css -o ./apps/main-app/public/styles/global.tmp.css --minify && \ 34 - mv ./apps/main-app/public/styles/global.tmp.css ./apps/main-app/public/styles/global.css 35 - RUN bunx @tailwindcss/cli -i ./apps/main-app/public/admin/styles.css -o ./apps/main-app/public/admin/styles.tmp.css --minify && \ 36 - mv ./apps/main-app/public/admin/styles.tmp.css ./apps/main-app/public/admin/styles.css 29 + # Production dependencies stage 30 + FROM oven/bun:1.3 AS prod-deps 37 31 38 - # Build frontend (transpile all .tsx entry points to .js) 39 - RUN bun build ./apps/main-app/public/index.tsx --outdir ./apps/main-app/public --target browser 40 - RUN bun build ./apps/main-app/public/admin/admin.tsx --outdir ./apps/main-app/public/admin --target browser 41 - RUN bun build ./apps/main-app/public/acceptable-use/acceptable-use.tsx --outdir ./apps/main-app/public/acceptable-use --target browser 42 - RUN bun build ./apps/main-app/public/editor/editor.tsx --outdir ./apps/main-app/public/editor --target browser 43 - RUN bun build ./apps/main-app/public/onboarding/onboarding.tsx --outdir ./apps/main-app/public/onboarding --target browser 32 + WORKDIR /app 44 33 45 - # Update HTML files to reference .js instead of .tsx 46 - RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/index.html 47 - RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/admin/index.html 48 - RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/acceptable-use/index.html 49 - RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/editor/index.html 50 - RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/onboarding/index.html 34 + COPY package.json bunfig.toml tsconfig.json bun.lock* ./ 35 + COPY packages ./packages 36 + COPY apps/main-app/package.json ./apps/main-app/package.json 37 + COPY apps/hosting-service/package.json ./apps/hosting-service/package.json 38 + COPY cli/ ./cli 51 39 52 - # Build backend as compiled binary 53 - RUN bun build \ 54 - --compile \ 55 - --target=bun \ 56 - --minify-whitespace \ 57 - --minify-syntax \ 58 - --outfile server \ 59 - ./apps/main-app/src/index.ts 40 + # Install only production dependencies 41 + RUN bun install --frozen-lockfile --production 42 + 43 + # Remove unnecessary large packages (bun is already in base image, these are dev tools) 44 + RUN rm -rf /app/node_modules/bun \ 45 + /app/node_modules/@oven \ 46 + /app/node_modules/prettier \ 47 + /app/node_modules/@ts-morph 60 48 61 - FROM gcr.io/distroless/base 49 + # Final stage - use distroless or slim debian-based image 50 + FROM debian:bookworm-slim 51 + 52 + # Install Bun runtime 53 + COPY --from=oven/bun:1.3 /usr/local/bin/bun /usr/local/bin/bun 62 54 63 55 WORKDIR /app 64 56 65 - COPY --from=build /app/server server 66 - COPY --from=build /app/apps/main-app/public /app/apps/main-app/public 57 + # Copy compiled server 58 + COPY --from=build /app/server /app/server 67 59 68 - ENV NODE_ENV=production 60 + # Copy public files 61 + COPY apps/main-app/public apps/main-app/public 69 62 70 - CMD ["./server"] 63 + # Copy production dependencies only 64 + COPY --from=prod-deps /app/node_modules /app/node_modules 71 65 72 - EXPOSE 8000 66 + # Copy configs 67 + COPY package.json bunfig.toml tsconfig.json /app/ 68 + COPY apps/main-app/tsconfig.json /app/apps/main-app/tsconfig.json 69 + COPY apps/main-app/package.json /app/apps/main-app/package.json 70 + 71 + # Create symlink for module resolution 72 + RUN ln -s /app/node_modules /app/apps/main-app/node_modules 73 + 74 + ENV PORT=8000 75 + 76 + EXPOSE 8000 77 + 78 + CMD ["./server"]