diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9b6033b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# Ignore all .env files in any directory or subdirectory +**/.env + +# Ignore node_modules and dist directories in any directory or subdirectory +**/node_modules +**/dist + +**/*.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d282b4f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Based on example: +FROM node:20-slim AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable + +FROM base AS build +COPY . /usr/src/app +WORKDIR /usr/src/app +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN pnpm run -r build +RUN pnpm deploy --filter=./apps/api --prod /prod/api + +# RUN pnpm deploy --filter=app2 --prod /prod/app2 + +FROM base AS api +COPY --from=build /prod/api /prod/api +WORKDIR /prod/api +CMD [ "pnpm", "start" ] + +# FROM base AS app2 +# COPY --from=build /prod/app2 /prod/app2 +# WORKDIR /prod/app2 +# EXPOSE 8001 +# CMD [ "pnpm", "start" ] \ No newline at end of file diff --git a/README.md b/README.md index 7b72213..c3f914e 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,16 @@ $ pnpm run test:e2e $ pnpm run test:cov ``` +# Deployment + +## Docker + +To build a Docker image for the API, navigate to the root directory of the monorepo and run the following command: + +``` +docker build . --target api --tag api:latest +``` + ## Docs Locally Swagger docs are available at http://localhost:3000/docs diff --git a/apps/api/package.json b/apps/api/package.json index 541d23a..982a3ff 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -38,5 +38,6 @@ "@types/express": "4.17.17", "@types/swagger-ui-express": "4.1.6", "tsx": "4.17.0" - } + }, + "packageManager": "pnpm@9.5.0+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d" }