From 5c5a89f03a761310a0798db9613020bbb4bc8e63 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Thu, 26 Oct 2023 04:01:14 +0800 Subject: [PATCH] Backend update dockerfile for production and dev --- elysia/Dockerfile | 3 ++- elysia/docker-compose.yml | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 elysia/docker-compose.yml diff --git a/elysia/Dockerfile b/elysia/Dockerfile index 2b2af6e..3fd5aff 100644 --- a/elysia/Dockerfile +++ b/elysia/Dockerfile @@ -6,10 +6,11 @@ WORKDIR /shortener-backend COPY ./package.json ./ COPY ./bun.lockb ./ -RUN bun install +RUN bun install --production COPY . . EXPOSE 3000 +ENV NODE_ENV production ENTRYPOINT [ "bun", "run", "./src/index.ts" ] diff --git a/elysia/docker-compose.yml b/elysia/docker-compose.yml new file mode 100644 index 0000000..3d28cf9 --- /dev/null +++ b/elysia/docker-compose.yml @@ -0,0 +1,15 @@ +--- +# docker-compose.yml +version: '3.9' +services: + app: + image: oven/bun + container_name: linkshortener_elysia_dev + # override default entrypoint allows us to do `bun install` before serving + entrypoint: [] + # execute bun install before we start the dev server in watch mode + command: /bin/sh -c 'bun install && bun run --watch src/index.ts' + # expose the right ports + ports: [3000:3000] + # setup a host mounted volume to sync changes to the container + volumes: [./:/home/bun/app]