2023-12-08 13:05:20 +00:00
|
|
|
# Dockerfile
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2024-01-14 19:49:34 +00:00
|
|
|
# Generate new bun lock
|
|
|
|
FROM base as lock
|
|
|
|
RUN mkdir -p /temp/lock
|
|
|
|
COPY package.json /temp/lock
|
|
|
|
RUN cd /temp/lock && bun install
|
|
|
|
|
2023-12-08 13:05:20 +00:00
|
|
|
# install dependencies into temp folder
|
|
|
|
# this will cache them and speed up future builds
|
|
|
|
FROM base AS install
|
|
|
|
# install with --production (exclude devDependencies)
|
|
|
|
RUN mkdir -p /temp/prod
|
2024-01-14 19:49:34 +00:00
|
|
|
COPY --from=lock /temp/lock/package.json /temp/lock/bun.lockb /temp/prod/
|
|
|
|
RUN cd /temp/prod && bun install --production --frozen-lockfile
|
2023-12-08 13:05:20 +00:00
|
|
|
|
2024-01-14 19:49:34 +00:00
|
|
|
# Copy production dependencies and source code into final image
|
2023-12-08 13:05:20 +00:00
|
|
|
FROM base AS release
|
|
|
|
COPY --from=install /temp/prod/node_modules node_modules
|
2024-01-14 19:49:34 +00:00
|
|
|
COPY --from=install /temp/prod/package.json .
|
|
|
|
COPY ./src ./src
|
2023-12-08 13:05:20 +00:00
|
|
|
|
|
|
|
# run the app
|
|
|
|
USER bun
|
2024-01-14 19:49:34 +00:00
|
|
|
ENV NODE_ENV production
|
2023-12-25 06:47:16 +00:00
|
|
|
EXPOSE 8080/tcp
|
2024-04-15 17:00:05 +00:00
|
|
|
ENTRYPOINT ["bun", "run", "start"]
|