forked from AFK-AlignedFamKernel/afk_monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Backend.Dockerfile
72 lines (50 loc) · 1.9 KB
/
Backend.Dockerfile
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Use a Node.js base image
FROM node:18-alpine AS base
# Set the working directory inside the container
WORKDIR /app
# Add an argument for the Telegram bot token
ARG TELEGRAM_BOT_TOKEN
# Set the environment variable
ENV TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
# Add an argument for th Indexer postgres url
ARG INDEXER_DATABASE_URL
# Set the environment variable
ENV INDEXER_DATABASE_URL=${INDEXER_DATABASE_URL}
# Add an argument for th Backend postgres url
ARG BACKEND_DATABASE_URL
# Set the environment variable
ENV BACKEND_DATABASE_URL=${BACKEND_DATABASE_URL}
# Add an argument for Telegram webapp
ARG TELEGRAM_WEB_APP
# Set the environment variable
ENV TELEGRAM_WEB_APP=${TELEGRAM_WEB_APP}
# Copy root-level package files
COPY package.json pnpm-workspace.yaml ./
# Install pnpm globally
RUN npm install -g pnpm
# Install all dependencies for the workspace, including common and data-backend
RUN pnpm install --force
# Copy the entire repository into the Docker container
COPY . .
# Build the indexer-prisma package
RUN pnpm --filter indexer-prisma build
# Build the data-backend package
# RUN pnpm --filter data-backend build:all
RUN pnpm --filter data-backend build:all_repo
# Use a smaller production base image
FROM node:18-alpine AS production
# Set the working directory in the production container
WORKDIR /app
# Copy the node_modules and built files from the base stage
COPY --from=base /app/node_modules ./node_modules
COPY --from=base /app/packages/common ./packages/common
COPY --from=base /app/packages/indexer-prisma ./packages/indexer-prisma
COPY --from=base /app/apps/data-backend/dist ./apps/data-backend/dist
# Copy only necessary files for the application to run
COPY apps/data-backend/package.json ./
# Set the environment variable to production
ENV NODE_ENV=production
# Expose the port your app runs on
EXPOSE 3000
# Command to start the application
CMD ["node", "apps/data-backend/dist/index.js"]