-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (31 loc) · 1.24 KB
/
Dockerfile
File metadata and controls
46 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Build stage
FROM node:lts-alpine AS base
RUN corepack enable && corepack prepare pnpm@10.33.2 --activate
ENV PNPM_HOME=/pnpm
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /app
# pnpm needs the whole repo
COPY . .
RUN --mount=type=cache,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm --filter @coursehub/backend db:generate
RUN pnpm --filter @coursehub/backend build
# Scope backend deps
RUN pnpm --filter @coursehub/backend --prod deploy /temp-prod
RUN cp -r apps/backend/build /temp-prod/build
# Production
FROM node:lts-alpine AS prod
WORKDIR /app
RUN apk add --no-cache postgresql-client curl
COPY --from=base /temp-prod/build ./build
COPY --from=base /temp-prod/node_modules ./node_modules
COPY --from=base /temp-prod/package.json ./package.json
ENV NODE_ENV=production
# GitHub link to repo
LABEL org.opencontainers.image.source="https://github.com/BrNi05/CourseHub" \
org.opencontainers.image.title="CourseHub Backend" \
org.opencontainers.image.description="CourseHub backend server image" \
org.opencontainers.image.licenses="Apache-2.0"
# Only checks if the server is running
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=2 \
CMD curl -f http://localhost:3000/api/health
CMD ["node", "build/main.js"]