-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathrailway.indexer-v2.Dockerfile
More file actions
65 lines (53 loc) · 2.44 KB
/
Copy pathrailway.indexer-v2.Dockerfile
File metadata and controls
65 lines (53 loc) · 2.44 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Use a Node.js base image
FROM node:20-alpine AS base
# Set the working directory inside the container
WORKDIR /build
# Copy repository into the Docker container
COPY . .
# when building image on local machine, remove .env files
RUN find . -name ".env" -type f | xargs rm -f
# Install libs + pnpm
# Install dependencies
# Build the project
RUN apk add --no-cache \
openssl \
libc6-compat && \
npm install -g pnpm && \
pnpm install && \
echo "Building indexer-v2-db package..." && \
pnpm run build:indexer-v2-db && \
echo "Building indexer-v2 app..." && \
pnpm --filter indexer-v2 build:all && \
echo "Build completed successfully"
WORKDIR /app
## Copy the node_modules and built files from the base stage
RUN echo "Copying files to production stage..." && \
ls -la /build/packages/ && \
ls -la /build/apps/ && \
mv /build/node_modules . && \
[ -d "/build/packages/common" ] && mv /build/packages/common ./node_modules/ || echo "common package not found" && \
[ -d "/build/packages/indexer-v2-db" ] && mv /build/packages/indexer-v2-db ./node_modules/ || echo "indexer-v2-db package not found" && \
mkdir -p apps/indexer-v2 && \
[ -d "/build/apps/indexer-v2/node_modules" ] && mv /build/apps/indexer-v2/node_modules ./apps/indexer-v2/ || echo "indexer-v2 node_modules not found" && \
[ -d "/build/apps/indexer-v2/.apibara/build" ] && mv /build/apps/indexer-v2/.apibara/build ./apps/indexer-v2/ || echo "apibara build not found" && \
[ -f "/build/apps/indexer-v2/package.json" ] && mv /build/apps/indexer-v2/package.json ./apps/indexer-v2/ || echo "indexer-v2 package.json not found" && \
[ -d "/build/apps/indexer-v2/.apibara" ] && mv /build/apps/indexer-v2/.apibara ./apps/indexer-v2/ || echo "apibara directory not found" && \
echo "File copying completed"
# Use a smaller production base image
FROM node:20-alpine AS production
# Install necessary dependencies in production
RUN apk add --no-cache \
openssl \
libc6-compat
# Set the working directory in the production container
WORKDIR /app
# Copy all necessary files in a single layer
COPY --from=base /app .
# Set the environment variable to production
ENV NODE_ENV=production
# Expose the port your app runs on
EXPOSE 3000
# Command to start the application
WORKDIR /app/apps/indexer-v2
CMD node build/start.mjs start --indexer ${INDEXER_NAME:-dao-factory}
# CMD node build/start.mjs start --indexer ${INDEXER_NAME:-dao-factory} --allow-env .env