This is it
This commit is contained in:
parent
54957dd711
commit
9f8c705224
4 changed files with 20 additions and 28 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -173,3 +173,5 @@ dist
|
||||||
|
|
||||||
# Finder (MacOS) folder config
|
# Finder (MacOS) folder config
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
build
|
21
Dockerfile
21
Dockerfile
|
@ -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
|
FROM oven/bun:1 as base
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# install dependencies into temp directory
|
|
||||||
# this will cache them and speed up future builds
|
|
||||||
FROM base AS install
|
FROM base AS install
|
||||||
RUN mkdir -p /temp/dev
|
RUN mkdir -p /temp/dev
|
||||||
COPY package.json bun.lockb /temp/dev/
|
COPY package.json bun.lockb /temp/dev/
|
||||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
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
|
FROM base AS prerelease
|
||||||
COPY --from=install /temp/dev/node_modules node_modules
|
COPY --from=install /temp/dev/node_modules node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# [optional] tests & build
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
# RUN bun test
|
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# copy production dependencies and source code into final image
|
|
||||||
FROM base AS release
|
FROM base AS release
|
||||||
COPY --from=install /temp/prod/node_modules node_modules
|
COPY --from=prerelease /usr/src/app/build/garf-api .
|
||||||
COPY --from=prerelease /usr/src/app/index.ts .
|
|
||||||
COPY --from=prerelease /usr/src/app/package.json .
|
|
||||||
|
|
||||||
# run the app
|
|
||||||
USER bun
|
USER bun
|
||||||
EXPOSE 3000/tcp
|
EXPOSE 3000/tcp
|
||||||
ENTRYPOINT [ "bun", "run", "index.ts" ]
|
RUN ls -lah
|
||||||
|
CMD [ "garf-api" ]
|
||||||
|
|
23
package.json
23
package.json
|
@ -1,11 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "garf-api",
|
"name": "garf-api",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"scripts": {
|
||||||
"@types/bun": "latest"
|
"build": "bun build . --compile --outfile=build/garf-api"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"@types/bun": "latest"
|
||||||
}
|
},
|
||||||
}
|
"peerDependencies": {
|
||||||
|
"typescript": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,3 +9,5 @@ Bun.serve({
|
||||||
return new Response("garf dont know what want...");
|
return new Response("garf dont know what want...");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("Listening on 0.0.0.0:3000");
|
||||||
|
|
Loading…
Reference in a new issue