40
Dockerfile
Normal file
40
Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# 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/app
|
||||||
|
|
||||||
|
# install dependencies into temp directory
|
||||||
|
# this will cache them and speed up future builds
|
||||||
|
FROM base AS install
|
||||||
|
RUN mkdir -p /tmp/dev
|
||||||
|
COPY package.json bun.lockb /tmp/dev/
|
||||||
|
RUN cd /tmp/dev && bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# install with --production (exclude devDependencies)
|
||||||
|
RUN mkdir -p /tmp/prod
|
||||||
|
COPY package.json bun.lockb /tmp/prod/
|
||||||
|
RUN cd /tmp/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 /tmp/dev/node_modules node_modules
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# [optional] tests & build
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
RUN bun test
|
||||||
|
RUN bun build --compile src/index.ts --outfile=aniplay
|
||||||
|
|
||||||
|
# copy production dependencies and source code into final image
|
||||||
|
FROM base AS release
|
||||||
|
COPY --from=install /tmp/prod/node_modules node_modules
|
||||||
|
COPY --from=prerelease /usr/app/src ./src
|
||||||
|
COPY --from=prerelease /usr/app/package.json .
|
||||||
|
COPY --from=prerelease /usr/app/tsconfig.json .
|
||||||
|
COPY --from=prerelease /usr/app/drizzle.config.ts .
|
||||||
|
|
||||||
|
# run the app
|
||||||
|
USER bun
|
||||||
|
EXPOSE 3000
|
||||||
|
ENTRYPOINT [ "bun", "run", "prod:server" ]
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "wrangler dev src/index.ts --port 8080",
|
"dev:cloudflare": "wrangler dev src/index.ts --port 8080",
|
||||||
|
"dev:server": "bun run --watch src/index.ts",
|
||||||
|
"prod:server": "bun run src/index.ts",
|
||||||
"deploy": "wrangler deploy --minify src/index.ts"
|
"deploy": "wrangler deploy --minify src/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user