bot-api/Dockerfile

33 lines
904 B
Docker

# 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
# Generate new bun lock
FROM base as lock
RUN mkdir -p /temp/lock
COPY package.json /temp/lock
RUN cd /temp/lock && bun install
# 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
COPY --from=lock /temp/lock/package.json /temp/lock/bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --production --frozen-lockfile
# Copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=install /temp/prod/package.json .
COPY ./src ./src
# run the app
USER bun
ENV NODE_ENV production
EXPOSE 8080/tcp
CMD ["bun", "run", "start"]