Skip to content

Commit

Permalink
test(docker): test alpine 3.21 + Node.js 20
Browse files Browse the repository at this point in the history
jkomyno committed Dec 17, 2024
1 parent 9605972 commit b3278dc
Showing 17 changed files with 1,708 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1757,6 +1757,8 @@ jobs:
- alpine-3.17-amd64-openssl-3.0.x
- alpine-3.21-arm64-openssl-3.0.x
- alpine-3.21-amd64-openssl-3.0.x
- alpine-3.21-node-20-arm64-openssl-3.0.x
- alpine-3.21-node-20-amd64-openssl-3.0.x
- alpine-latest-amd64-openssl-3.0.x
- alpine-latest-arm64-openssl-3.0.x
- amazonlinux-2022-amd64-openssl-3.0.x
42 changes: 42 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1

FROM node:20-alpine3.21

WORKDIR /usr/src/app
COPY --from=app . ./
COPY --from=utils . ./

RUN apk update

# Only OpenSSL 3 is expected to be on this system
RUN if [ ! -e /usr/lib/libssl.so.3 ]; then echo 'OpenSSL 3 not found in /usr/lib/libssl.so.3'; exit 1; fi
RUN if [ -e /usr/lib/libssl.so.1.1 ]; then echo 'OpenSSL 1.1 must not be installed (found in /usr/lib/libssl.so.1.1)'; exit 1; fi

# Ensure the old platform-specific paths are not containing OpenSSL
RUN if [ -e /lib/libssl.so.3 ]; then echo '/lib/libssl.so.3 must not exist'; exit 1; fi
RUN if [ -e /lib/libssl.so.1.1 ]; then echo '/lib/libssl.so.1.1'; exit 1; fi

# expected target platform for Prisma, retrieved by `prisma -v`
ARG EXPECTED_PRISMA_TARGET_PLATFORM="linux-musl-openssl-3.0.x"
ARG PRISMA_ENGINES_MIRROR
ARG PRISMA_CLIENT_ENGINE_TYPE
ARG PRISMA_CLI_QUERY_ENGINE_TYPE
ARG CI
ARG DEBUG
ARG PRISMA_TELEMETRY_INFORMATION

ENV PRISMA_ENGINES_MIRROR=$PRISMA_ENGINES_MIRROR
ENV PRISMA_CLIENT_ENGINE_TYPE=$PRISMA_CLIENT_ENGINE_TYPE
ENV PRISMA_CLI_QUERY_ENGINE_TYPE=$PRISMA_CLI_QUERY_ENGINE_TYPE
ENV CI=$CI
ENV DEBUG=$DEBUG
ENV PRISMA_TELEMETRY_INFORMATION=$PRISMA_TELEMETRY_INFORMATION
ENV EXPECTED_PRISMA_TARGET_PLATFORM=$EXPECTED_PRISMA_TARGET_PLATFORM

RUN npm i -g pnpm@8
RUN pnpm install
RUN ./version.sh
RUN pnpm prisma generate

CMD node server.js
EXPOSE 3000
7 changes: 7 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OS support: alpine-3.21-node-20-amd64-openssl-3.0.x

- Base Docker image: `node:20-alpine3.21`
- OS: Linux Alpine 3.21
- Arch: amd64 (x86_64)
- OpenSSL location: `/usr/lib/libssl.so.3`
- Binary target: `linux-musl-openssl-3.0.x`
17 changes: 17 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@prisma/alpine-3.21-node-20-amd64-openssl-3.0.x",
"license": "MIT",
"devDependencies": {
"@types/node": "18.19.67",
"prisma": "6.1.0-dev.34",
"ts-node": "10.9.2",
"typescript": "5.6.3"
},
"scripts": {
"start": "node server.js"
},
"dependencies": {
"@prisma/client": "6.1.0-dev.34",
"express": "4.21.1"
}
}
673 changes: 673 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id String @id @default(cuid())
email String @unique
name String?
}
34 changes: 34 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -eux
export DEBUG="*"

DOCKER_PLATFORM_ARCH="linux/amd64"
PRISMA_DOCKER_IMAGE_NAME="prisma-alpine-3.21-node-20-amd64-openssl-3.0.x"

docker buildx build --load \
--platform="${DOCKER_PLATFORM_ARCH}" \
--build-context app=. \
--build-context utils=../../docker/_utils \
--build-arg DEBUG=${DEBUG} \
--build-arg PRISMA_TELEMETRY_INFORMATION="${PRISMA_TELEMETRY_INFORMATION}" \
--build-arg PRISMA_ENGINES_MIRROR=${PRISMA_ENGINES_MIRROR} \
--build-arg PRISMA_CLIENT_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
--build-arg PRISMA_CLI_QUERY_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
--build-arg CI=${CI} \
. -t "${PRISMA_DOCKER_IMAGE_NAME}" \
--progress plain

docker run -p 3000:3000 \
-e DEBUG=${DEBUG} \
-e DATABASE_URL=${DATABASE_URL} \
-e CI=${CI} \
-e PRISMA_CLIENT_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
-e PRISMA_CLI_QUERY_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
-e PRISMA_TELEMETRY_INFORMATION="${PRISMA_TELEMETRY_INFORMATION}" \
"${PRISMA_DOCKER_IMAGE_NAME}" &

sleep 15

pnpm install
pnpm prisma generate
18 changes: 18 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

const express = require('express')
const app = express()
const port = 3000

const { PrismaClient } = require('@prisma/client')

const client = new PrismaClient()

app.get('/', async (req, res) => {
const data = await client.user.findMany()
res.send(JSON.stringify(data))
})

app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`)
})
15 changes: 15 additions & 0 deletions docker/alpine-3.21-node-20-amd64-openssl-3.0.x/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -eu

expected="[]"
actual=$(curl localhost:3000)

if [ "$expected" != "$actual" ]; then
echo "expected '$expected', got '$actual'"
docker stop $(docker ps -a -q)
exit 1
fi

echo "result: $actual"
docker stop $(docker ps -a -q)
42 changes: 42 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1

FROM node:20-alpine3.21

WORKDIR /usr/src/app
COPY --from=app . ./
COPY --from=utils . ./

RUN apk update

# Only OpenSSL 3 is expected to be on this system
RUN if [ ! -e /usr/lib/libssl.so.3 ]; then echo 'OpenSSL 3 not found in /usr/lib/libssl.so.3'; exit 1; fi
RUN if [ -e /usr/lib/libssl.so.1.1 ]; then echo 'OpenSSL 1.1 must not be installed (found in /usr/lib/libssl.so.1.1)'; exit 1; fi

# Ensure the old platform-specific paths are not containing OpenSSL
RUN if [ -e /lib/libssl.so.3 ]; then echo '/lib/libssl.so.3 must not exist'; exit 1; fi
RUN if [ -e /lib/libssl.so.1.1 ]; then echo '/lib/libssl.so.1.1'; exit 1; fi

# expected target platform for Prisma, retrieved by `prisma -v`
ARG EXPECTED_PRISMA_TARGET_PLATFORM="linux-musl-arm64-openssl-3.0.x"
ARG PRISMA_ENGINES_MIRROR
ARG PRISMA_CLIENT_ENGINE_TYPE
ARG PRISMA_CLI_QUERY_ENGINE_TYPE
ARG CI
ARG DEBUG
ARG PRISMA_TELEMETRY_INFORMATION

ENV PRISMA_ENGINES_MIRROR=$PRISMA_ENGINES_MIRROR
ENV PRISMA_CLIENT_ENGINE_TYPE=$PRISMA_CLIENT_ENGINE_TYPE
ENV PRISMA_CLI_QUERY_ENGINE_TYPE=$PRISMA_CLI_QUERY_ENGINE_TYPE
ENV CI=$CI
ENV DEBUG=$DEBUG
ENV PRISMA_TELEMETRY_INFORMATION=$PRISMA_TELEMETRY_INFORMATION
ENV EXPECTED_PRISMA_TARGET_PLATFORM=$EXPECTED_PRISMA_TARGET_PLATFORM

RUN npm i -g pnpm@8
RUN pnpm install
RUN ./version.sh
RUN pnpm prisma generate

CMD node server.js
EXPOSE 3000
7 changes: 7 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OS support: alpine-3.21-node-20-arm64-openssl-3.0.x

- Base Docker image: `node:20-alpine3.21`
- OS: Linux Alpine 3.21
- Arch: arm64 (aarch64)
- OpenSSL location: `/usr/lib/libssl.so.3`
- Binary target: `linux-musl-arm64-openssl-3.0.x`
17 changes: 17 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@prisma/alpine-3.21-node-20-arm64-openssl-3.0.x",
"license": "MIT",
"devDependencies": {
"@types/node": "18.19.67",
"prisma": "6.1.0-dev.34",
"ts-node": "10.9.2",
"typescript": "5.6.3"
},
"scripts": {
"start": "node server.js"
},
"dependencies": {
"@prisma/client": "6.1.0-dev.34",
"express": "4.21.1"
}
}
739 changes: 739 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id String @id @default(cuid())
email String @unique
name String?
}
34 changes: 34 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -eux
export DEBUG="*"

DOCKER_PLATFORM_ARCH="linux/arm64"
PRISMA_DOCKER_IMAGE_NAME="prisma-alpine-3.21-node-20-arm64-openssl-3.0.x"

docker buildx build --load \
--platform="${DOCKER_PLATFORM_ARCH}" \
--build-context app=. \
--build-context utils=../../docker/_utils \
--build-arg DEBUG=${DEBUG} \
--build-arg PRISMA_TELEMETRY_INFORMATION="${PRISMA_TELEMETRY_INFORMATION}" \
--build-arg PRISMA_ENGINES_MIRROR=${PRISMA_ENGINES_MIRROR} \
--build-arg PRISMA_CLIENT_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
--build-arg PRISMA_CLI_QUERY_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
--build-arg CI=${CI} \
. -t "${PRISMA_DOCKER_IMAGE_NAME}" \
--progress plain

docker run -p 3000:3000 \
-e DEBUG=${DEBUG} \
-e DATABASE_URL=${DATABASE_URL} \
-e CI=${CI} \
-e PRISMA_CLIENT_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
-e PRISMA_CLI_QUERY_ENGINE_TYPE=${PRISMA_CLIENT_ENGINE_TYPE} \
-e PRISMA_TELEMETRY_INFORMATION="${PRISMA_TELEMETRY_INFORMATION}" \
"${PRISMA_DOCKER_IMAGE_NAME}" &

sleep 15

pnpm install
pnpm prisma generate
18 changes: 18 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

const express = require('express')
const app = express()
const port = 3000

const { PrismaClient } = require('@prisma/client')

const client = new PrismaClient()

app.get('/', async (req, res) => {
const data = await client.user.findMany()
res.send(JSON.stringify(data))
})

app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`)
})
15 changes: 15 additions & 0 deletions docker/alpine-3.21-node-20-arm64-openssl-3.0.x/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -eu

expected="[]"
actual=$(curl localhost:3000)

if [ "$expected" != "$actual" ]; then
echo "expected '$expected', got '$actual'"
docker stop $(docker ps -a -q)
exit 1
fi

echo "result: $actual"
docker stop $(docker ps -a -q)

0 comments on commit b3278dc

Please sign in to comment.