Skip to content

Commit ddf1333

Browse files
authored
Merge pull request #13 from cardanoapi/update/dockerfile
Fix deployment issues caused due to prisma
2 parents 4484e5f + a937290 commit ddf1333

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

Dockerfile

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
1-
FROM node:20-alpine AS api_base
2-
WORKDIR /prisma
3-
RUN yarn add prisma
4-
1+
FROM node:20-alpine AS base
52
WORKDIR /app
6-
COPY ./package.json ./yarn.lock ./
7-
# Copy the rest of the application code to the container
8-
RUN yarn install --frozen-lockfile --production
93

10-
COPY ./prisma ./prisma
11-
RUN /prisma/node_modules/.bin/prisma generate
4+
# Minimal dependencies to fix the Prisma OpenSSL warning
5+
RUN apk add --no-cache openssl openssl-dev
6+
7+
COPY package.json yarn.lock ./
8+
RUN yarn install --frozen-lockfile
129

10+
COPY prisma ./prisma
11+
RUN yarn prisma generate
1312

14-
FROM api_base AS builder
15-
RUN yarn install
16-
COPY ./ ./
13+
COPY . .
1714
RUN yarn build
1815
RUN cp ./swagger.yaml ./dist
1916

17+
# ---------- Final lightweight image ----------
18+
FROM node:20-alpine AS production
19+
RUN apk add --no-cache openssl
2020

21-
22-
FROM node:20-alpine
23-
RUN apk add openssl
21+
# Create a non-root user
2422
USER node
25-
2623
WORKDIR /api
27-
COPY --from=api_base --chown=node:node /app/node_modules node_modules
28-
COPY --from=builder --chown=node:node /app/prisma prisma
29-
COPY --from=builder --chown=node:node /app/dist ./
3024

31-
# Expose the port the app runs on (if applicable)
32-
EXPOSE 8080
25+
# Copy only what's needed for production runtime
26+
COPY --from=base --chown=node:node /app/node_modules ./node_modules
27+
COPY --from=base --chown=node:node /app/prisma ./prisma
28+
COPY --from=base --chown=node:node /app/dist ./
3329

34-
# Command to run the application
35-
CMD ["node", "/api/index.js"]
30+
# Set environment variables
31+
ENV NODE_ENV=production
32+
ENV ENABLE_TRACING=false
33+
ENV RUST_LOG=info
3634

35+
# Expose app port
36+
EXPOSE 8080
3737

38+
# Start the app
39+
CMD ["node", "index.js"]

src/health/healthCheck.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const getBlockInfo = async (req: Request, res: Response) => {
3535
}
3636

3737
const blockInfo = {
38-
blockHash: latestBlock.hash.toString("hex"),
38+
blockHash: (latestBlock.hash as Buffer).toString('hex'),
3939
blockNo: latestBlock.block_no,
4040
slotNo: latestBlock.slot_no?.toString(),
4141
blockTime: latestBlock.time.toISOString(),

0 commit comments

Comments
 (0)