Skip to content

Commit ba8ef05

Browse files
committed
feat: add oracle thick docker image
1 parent c806636 commit ba8ef05

File tree

4 files changed

+184
-1
lines changed

4 files changed

+184
-1
lines changed

.github/workflows/docker-publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# 1. Always pushes to the 'latest' tag when changes are pushed to the main branch
55
# 2. If package.json version changes, also pushes a version-specific tag
66
# 3. Builds for both amd64 and arm64 architectures
7+
# 4. Builds Oracle thick mode image for Oracle 11g compatibility
78

89
name: Publish to docker hub
910

@@ -13,6 +14,7 @@ on:
1314

1415
env:
1516
IMAGE_NAME: bytebase/dbhub
17+
ORACLE_THICK_IMAGE_NAME: bytebase/dbhub-oracle-thick
1618

1719
jobs:
1820
build-and-push:
@@ -83,3 +85,31 @@ jobs:
8385
tags: ${{ steps.prep.outputs.TAGS }}
8486
cache-from: type=gha
8587
cache-to: type=gha,mode=max
88+
89+
- name: Prepare Oracle Thick mode Docker tags
90+
id: prep-oracle
91+
run: |
92+
# Always include latest tag
93+
ORACLE_TAGS="${{ env.ORACLE_THICK_IMAGE_NAME }}:latest"
94+
95+
# Add version tag if version changed
96+
if [[ "${{ steps.check-version.outputs.VERSION_CHANGED }}" == "true" ]]; then
97+
VERSION="${{ steps.check-version.outputs.VERSION }}"
98+
ORACLE_TAGS="$ORACLE_TAGS,${{ env.ORACLE_THICK_IMAGE_NAME }}:$VERSION"
99+
echo "Publishing Oracle image with tags: latest, $VERSION"
100+
else
101+
echo "Publishing Oracle image with tag: latest only"
102+
fi
103+
104+
echo "ORACLE_TAGS=$ORACLE_TAGS" >> $GITHUB_OUTPUT
105+
106+
- name: Build and push Oracle thick client Docker image
107+
uses: docker/build-push-action@v5
108+
with:
109+
context: .
110+
file: ./Dockerfile.oracle-thick
111+
push: true
112+
platforms: linux/amd64
113+
tags: ${{ steps.prep-oracle.outputs.ORACLE_TAGS }}
114+
cache-from: type=gha,scope=oracle-build
115+
cache-to: type=gha,scope=oracle-build,mode=max

Dockerfile.oracle

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
FROM node:22-slim AS builder
2+
3+
WORKDIR /app
4+
5+
# Copy package.json and pnpm-lock.yaml
6+
COPY package.json pnpm-lock.yaml ./
7+
8+
# Install pnpm
9+
RUN corepack enable && corepack prepare pnpm@latest --activate
10+
11+
# Install dependencies
12+
RUN pnpm install
13+
14+
# Copy source code
15+
COPY . .
16+
17+
# Build the application
18+
RUN pnpm run build
19+
20+
# Production stage with Oracle Instant Client
21+
FROM node:22-slim
22+
23+
WORKDIR /app
24+
25+
# Install dependencies for Oracle Instant Client
26+
RUN apt-get update && apt-get install -y \
27+
libaio1 \
28+
unzip \
29+
curl \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
# Install Oracle Instant Client (adjust version as needed)
33+
WORKDIR /opt/oracle
34+
RUN curl -Lo instantclient-basic-linux.zip https://download.oracle.com/otn_software/linux/instantclient/219000/instantclient-basic-linux.x64-21.9.0.0.0dbru.zip \
35+
&& unzip instantclient-basic-linux.zip \
36+
&& rm instantclient-basic-linux.zip \
37+
&& cd instantclient* \
38+
&& echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf \
39+
&& ldconfig
40+
41+
# Set Oracle environment variables
42+
ENV ORACLE_LIB_DIR=/opt/oracle/instantclient_21_9
43+
44+
# Back to app directory
45+
WORKDIR /app
46+
47+
# Copy only production files
48+
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
49+
50+
# Install pnpm
51+
RUN corepack enable && corepack prepare pnpm@latest --activate
52+
53+
# Install production dependencies only
54+
RUN pnpm install --prod
55+
56+
# Copy built application from builder stage
57+
COPY --from=builder /app/dist ./dist
58+
59+
# Expose ports
60+
EXPOSE 8080
61+
62+
# Set environment variables
63+
ENV NODE_ENV=production
64+
65+
# Run the server
66+
ENTRYPOINT ["node", "dist/index.js"]

Dockerfile.oracle-thick

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Dockerfile for Oracle Thick mode
2+
# This build includes the Oracle Instant Client for compatibility with Oracle 11g and older versions
3+
# Uses the thick client connection mode instead of the thin mode for better compatibility with legacy systems
4+
5+
FROM node:22-slim AS builder
6+
7+
WORKDIR /app
8+
9+
# Copy package.json and pnpm-lock.yaml
10+
COPY package.json pnpm-lock.yaml ./
11+
12+
# Install pnpm
13+
RUN corepack enable && corepack prepare pnpm@latest --activate
14+
15+
# Install dependencies
16+
RUN pnpm install
17+
18+
# Copy source code
19+
COPY . .
20+
21+
# Build the application
22+
RUN pnpm run build
23+
24+
# Production stage with Oracle Instant Client
25+
FROM node:22-slim
26+
27+
WORKDIR /app
28+
29+
# Install dependencies for Oracle Instant Client
30+
RUN apt-get update && apt-get install -y \
31+
libaio1 \
32+
unzip \
33+
curl \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
# Install Oracle Instant Client (adjust version as needed)
37+
WORKDIR /opt/oracle
38+
RUN curl -Lo instantclient-basic-linux.zip https://download.oracle.com/otn_software/linux/instantclient/219000/instantclient-basic-linux.x64-21.9.0.0.0dbru.zip \
39+
&& unzip instantclient-basic-linux.zip \
40+
&& rm instantclient-basic-linux.zip \
41+
&& cd instantclient* \
42+
&& echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf \
43+
&& ldconfig
44+
45+
# Set Oracle environment variables
46+
ENV ORACLE_LIB_DIR=/opt/oracle/instantclient_21_9
47+
48+
# Back to app directory
49+
WORKDIR /app
50+
51+
# Copy only production files
52+
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
53+
54+
# Install pnpm
55+
RUN corepack enable && corepack prepare pnpm@latest --activate
56+
57+
# Install production dependencies only
58+
RUN pnpm install --prod
59+
60+
# Copy built application from builder stage
61+
COPY --from=builder /app/dist ./dist
62+
63+
# Expose ports
64+
EXPOSE 8080
65+
66+
# Set environment variables
67+
ENV NODE_ENV=production
68+
69+
# Run the server
70+
ENTRYPOINT ["node", "dist/index.js"]

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ docker run --rm --init \
9898
--dsn "oracle://username:password@localhost:1521/service_name"
9999
```
100100

101+
```bash
102+
# Oracle example with thick mode for connecting to 11g or older
103+
docker run --rm --init \
104+
--name dbhub \
105+
--publish 8080:8080 \
106+
bytebase/dbhub-oracle-thick \
107+
--transport sse \
108+
--port 8080 \
109+
--dsn "oracle://username:password@localhost:1521/service_name"
110+
```
111+
101112
### NPM
102113

103114
```bash
@@ -223,7 +234,13 @@ DBHub supports the following database connection string formats:
223234

224235
#### Oracle
225236

226-
If you see the error "NJS-138: connections to this database server version are not supported by node-oracledb in Thin mode", you need to use Thick mode as described below. To enable Thick mode:
237+
If you see the error "NJS-138: connections to this database server version are not supported by node-oracledb in Thin mode", you need to use Thick mode as described below.
238+
239+
##### Docker
240+
241+
Use `bytebase/dbhub-oracle-thick` instead of `bytebase/dbhub` docker image.
242+
243+
##### npx
227244

228245
1. Download and install [Oracle Instant Client](https://www.oracle.com/database/technologies/instant-client/downloads.html) for your platform
229246
1. Set the `ORACLE_LIB_DIR` environment variable to the path of your Oracle Instant Client:

0 commit comments

Comments
 (0)