diff --git a/Dockerfile b/Dockerfile index 376565c..94315cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,17 @@ -FROM oven/bun AS build +FROM oven/bun:alpine AS build WORKDIR /app # Cache packages installation -COPY package.json package.json -COPY bun.lock bun.lock +COPY package.json bun.lock ./ -RUN bun install +# Install dependencies +RUN bun install --frozen-lockfile +# Copy source files COPY ./src ./src COPY ./prisma ./prisma -COPY ./tsconfig.json tsconfig.json +COPY ./tsconfig.json ./ ENV NODE_ENV=production @@ -25,14 +26,26 @@ RUN bun build \ --outfile server \ ./src/index.ts +FROM alpine AS curl-downloader +RUN apk add --no-cache curl + FROM gcr.io/distroless/base WORKDIR /app +# Copy the compiled binaries COPY --from=build /app/server server +COPY --from=curl-downloader /usr/bin/curl /usr/bin/curl + +# Ensure the binary is executable +USER nonroot:nonroot ENV NODE_ENV=production -CMD ["./server"] +# Health check +HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ + CMD ["/usr/bin/curl", "-f", "http://localhost:3000/health"] + +EXPOSE 3000 -EXPOSE 3000 \ No newline at end of file +CMD ["./server"] \ No newline at end of file