From 59f21ebf34197b33ad8c2a92b8080fad4d43b71f Mon Sep 17 00:00:00 2001 From: Francesco Minnocci Date: Wed, 30 Jul 2025 19:47:57 +0200 Subject: [PATCH] fix docker --- .dockerignore | 4 ++++ Dockerfile | 28 +++++++++++++--------------- package.json | 4 ++++ 3 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cf79371 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +Dockerfile +node_modules +.git +*.local* diff --git a/Dockerfile b/Dockerfile index 549e502..ffbaeff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,35 +4,33 @@ # see all versions at https://hub.docker.com/r/oven/bun/tags FROM oven/bun:1-alpine AS base WORKDIR /app +RUN apk add --no-cache \ + git \ + curl \ + build-base \ + python3 -# install dependencies into temp directory -# this will cache them and speed up future builds +# install dependencies into temp directory to cache them and speed up future builds FROM base AS install RUN mkdir -p /temp/dev COPY package.json bun.lockb /temp/dev/ RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) RUN mkdir -p /temp/prod COPY package.json bun.lockb /temp/prod/ RUN cd /temp/prod && bun install --frozen-lockfile --production -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image +# copy node_modules from temp directory and copy (non-ignored) project files into the image FROM base AS prerelease COPY --from=install /temp/dev/node_modules node_modules COPY . . - -# build RUN bun run build # copy production dependencies and source code into final image FROM base AS release COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /app/index.ts . -COPY --from=prerelease /app/package.json . - -# run the app -USER bun -EXPOSE 3000 -CMD bun run ./dist/server/entry.mjs \ No newline at end of file +COPY --from=prerelease /app/dist ./dist +COPY package.json .env . +ENV HOST=0.0.0.0 +ENV PORT=3000 +EXPOSE 3000/tcp +CMD bun run start diff --git a/package.json b/package.json index 8aa0c01..a2cc495 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "scripts": { "dev": "run-s astro:sync astro:dev", "build": "run-s astro:build", + "astro:server": "bun run ./dist/server/entry.mjs", + "drizzle:migrate": "drizzle-kit migrate", + "drizzle:generate": "drizzle-kit generate", + "start": "run-s drizzle:migrate astro:server", "astro:sync": "astro sync", "astro:dev": "astro dev", "astro:build": "astro check && astro build"