node:20-alpine OpenSsl deployment issue

Hi all! I have been having the openssl issue with my node:20-alpine Dockerfile. Here is the Dockerfile:
FROM node:20-alpine AS builder
# ENV TURBO_TEAM=
# ENV TURBO_TOKEN=
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN mv ._env .env
RUN mv ._gitignore .gitignore
RUN turbo prune --scope=api --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:20-alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
RUN apk add --update python3 make gcc postgresql-dev g++ && rm -rf /var/cache/apk/*
WORKDIR /app

# First install dependencies (as they change less often)
COPY ._gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install

# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
COPY ._env .env

RUN cd packages/database && npx prisma generate

# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM

# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN

RUN npm i typescript -g
RUN npm i tsup -g
RUN yarn turbo run build --filter=api...

FROM node:20-alpine AS runner
WORKDIR /app

# Don't run production as root
RUN apk update && apk add bash

# Installing chrome for puppeteer
RUN apk add --no-cache chromium --repository=http://dl-cdn.alpinelinux.org/alpine/v3.10/main

RUN addgroup --system --gid 1001 expressjs
RUN adduser --system --uid 1001 expressjs
USER expressjs
COPY --from=installer /app .


CMD SERVER_PORT=8080 node apps/api/dist/index.js
FROM node:20-alpine AS builder
# ENV TURBO_TEAM=
# ENV TURBO_TOKEN=
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN mv ._env .env
RUN mv ._gitignore .gitignore
RUN turbo prune --scope=api --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:20-alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
RUN apk add --update python3 make gcc postgresql-dev g++ && rm -rf /var/cache/apk/*
WORKDIR /app

# First install dependencies (as they change less often)
COPY ._gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install

# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
COPY ._env .env

RUN cd packages/database && npx prisma generate

# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM

# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN

RUN npm i typescript -g
RUN npm i tsup -g
RUN yarn turbo run build --filter=api...

FROM node:20-alpine AS runner
WORKDIR /app

# Don't run production as root
RUN apk update && apk add bash

# Installing chrome for puppeteer
RUN apk add --no-cache chromium --repository=http://dl-cdn.alpinelinux.org/alpine/v3.10/main

RUN addgroup --system --gid 1001 expressjs
RUN adduser --system --uid 1001 expressjs
USER expressjs
COPY --from=installer /app .


CMD SERVER_PORT=8080 node apps/api/dist/index.js
2 Replies
Thailan
ThailanOP2d ago
Following along the other questions lead me to try different versions for node:20-alpine, I tried: -node:18-slim -node:18-alpine3.20 -node:18-alpine also tried adding this to my Dockerfile, still no luck: RUN ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3 after trying these now I can't even reproduce the same issue (tried reverting the version back to node:20-alpine), now my deployment says: FATAL: password authentication failed for user "postgres" DETAIL: Connection matched file "/pgsql/data/pg_hba.conf" line 81: "hostnossl all all all md5" any help would be appreciated Update: Downgraded my prisma version from "@prisma/client": "^5.16.0" to "@prisma/client": "5.12.1" this reproduced the openssl error back again then i changed "FROM node:20-alpine" to "FROM node:18-alpine3.20" and it works fine now
jonfanz
jonfanz2d ago
You can also try FROM node:20-alpine3.20 and that should resolve your issue as well If you want to stay on Node 20
Want results from more Discord servers?
Add your server