Skip to content

Commit

Permalink
feat: add docker image for api
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkenj1 committed Aug 29, 2024
1 parent 435d870 commit 4a17ec6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"@types/express": "4.17.17",
"@types/swagger-ui-express": "4.1.6",
"tsx": "4.17.0"
}
},
"packageManager": "[email protected]+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d"
}

0 comments on commit 4a17ec6

Please sign in to comment.