diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d2e713 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.DS_Store +node_modules +/build +/.svelte-kit +/package +.vercel +.output +vite.config.js.timestamp-* +vite.config.ts.timestamp-* +package-lock.json +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..888d326 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM oven/bun:1 as base +WORKDIR /usr/src/app + +FROM base AS install +RUN mkdir -p /temp/dev +COPY package.json bun.lockb /temp/dev/ +RUN cd /temp/dev && bun install --frozen-lockfile + +RUN mkdir -p /temp/prod +COPY package.json bun.lockb /temp/prod/ +RUN cd /temp/prod && bun install --frozen-lockfile --production + +FROM base AS prerelease +COPY --from=install /temp/dev/node_modules node_modules +COPY . . + +ENV NODE_ENV=production +RUN bun test +RUN bun run build + +FROM base AS release +COPY --from=install /temp/prod/node_modules node_modules +COPY --from=prerelease /usr/src/app/index.ts . +COPY --from=prerelease /usr/src/app/package.json . + +USER bun +EXPOSE 3000/tcp +ENTRYPOINT [ "bun", "run", "build/index.js" ]