From 72837c4b362fd4ad32f7762f5a6c45f050373f04 Mon Sep 17 00:00:00 2001 From: LovelessCodes Date: Wed, 8 May 2024 09:30:10 +0100 Subject: [PATCH] added: dockerfile & dockerignore --- .dockerignore | 15 +++++++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9b49524 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode +Makefile +helm-charts +.env +.editorconfig +.idea +coverage* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..868cc1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use the official Node.js image as the base image +FROM oven/bun:1 as base + +# Set the working directory inside the container +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/prod +COPY package.json bun.lockb /temp/prod/ +RUN cd /temp/prod && bun install --frozen-lockfile --production + +# [optional] tests & build +ENV NODE_ENV=production +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 . + +USER bun + +# Expose the port that the application will be listening on +EXPOSE 3000/tcp + +# Run the application +ENTRYPOINT [ "bun", "run", "index.ts" ] \ No newline at end of file