diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7ccb601 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,40 @@ +node_modules + +# output +out +dist +*.tgz +.nitro +.tanstack +.output + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store + +## Panda +styled-system +styled-system-studio \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b46754d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +FROM oven/bun:1.3.10-alpine AS base + +# Add metadata labels +LABEL maintainer="jugger@srjuggernaut.dev" +LABEL description="Blog application built with TanStack Start" + +FROM base AS builder + +WORKDIR /app +COPY . . + +# Set proper environment +ENV BUILD=true + +# Install all dependencies for build (dev + prod) +RUN bun install --frozen-lockfile +RUN bun run build + + +FROM base AS installer + +WORKDIR /app +COPY . . + +# Set proper environment +ENV NODE_ENV=production + +# Install all dependencies for production +RUN bun install --frozen-lockfile --production + + +FROM base AS runner + +WORKDIR /app + +# Install curl for health checks +RUN apk add --no-cache curl + +COPY --from=installer /app/node_modules /app/node_modules +COPY --from=builder /app/dist /app/dist +COPY --from=builder /app/server.ts /app/server.ts + +ENV NODE_ENV=production + +EXPOSE 3000/tcp + +# Add health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:3000/ || exit 1 + +CMD ["bun", "server.ts"]