This is it

This commit is contained in:
cirroskais 2024-03-18 16:08:10 -04:00
parent 54957dd711
commit 9f8c705224
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D
4 changed files with 20 additions and 28 deletions

2
.gitignore vendored
View file

@ -173,3 +173,5 @@ dist
# Finder (MacOS) folder config
.DS_Store
build

View file

@ -1,38 +1,23 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app
# install dependencies into temp directory
# this will 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
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
# [optional] tests & build
ENV NODE_ENV=production
# RUN bun test
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 /usr/src/app/index.ts .
COPY --from=prerelease /usr/src/app/package.json .
COPY --from=prerelease /usr/src/app/build/garf-api .
# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "index.ts" ]
RUN ls -lah
CMD [ "garf-api" ]

View file

@ -1,11 +1,14 @@
{
"name": "garf-api",
"module": "src/index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
"name": "garf-api",
"module": "src/index.ts",
"type": "module",
"scripts": {
"build": "bun build . --compile --outfile=build/garf-api"
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}

View file

@ -9,3 +9,5 @@ Bun.serve({
return new Response("garf dont know what want...");
},
});
console.log("Listening on 0.0.0.0:3000");