-
Notifications
You must be signed in to change notification settings - Fork 210
Expand file tree
/
Copy pathDockerfile
More file actions
89 lines (71 loc) · 2.78 KB
/
Dockerfile
File metadata and controls
89 lines (71 loc) · 2.78 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Build Stage
FROM golang:1.25.8-bookworm AS builder
WORKDIR /home/app
COPY . .
ARG DRIVER_NAME=olake
# DB2 conditional setup
RUN if [ "$DRIVER_NAME" = "db2" ]; then \
go run github.com/ibmdb/go_ibm_db/installer@v0.5.4; \
else \
# for other drivers, create empty clidriver directory to avoid build failure
mkdir -p /go/pkg/mod/github.com/ibmdb/clidriver; \
fi
# Build the Go binary
WORKDIR /home/app/drivers/${DRIVER_NAME}
RUN if [ "$DRIVER_NAME" = "db2" ] && [ "$(uname -m)" != "x86_64" ]; then \
echo "DB2 driver is only supported on x86_64 (amd64) architecture." && \
echo "IBM does not provide ARM64 clidriver." && \
exit 1; \
elif [ "$DRIVER_NAME" = "db2" ]; then \
export IBM_DB_HOME=/go/pkg/mod/github.com/ibmdb/clidriver && \
export CGO_CFLAGS="-I$IBM_DB_HOME/include" && \
export CGO_LDFLAGS="-L$IBM_DB_HOME/lib -Wl,-rpath,$IBM_DB_HOME/lib" && \
export LD_LIBRARY_PATH=$IBM_DB_HOME/lib && \
go build -o /olake main.go; \
else \
CGO_ENABLED=0 go build -o /olake main.go; \
fi
# Final Runtime Stage Base
FROM debian:bookworm-slim AS runtime-base-stage
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
openjdk-17-jre-headless \
libxml2 \
ca-certificates \
libpam-modules \
libcrypt1 \
&& rm -rf /var/lib/apt/lists/*
# Driver metadata
ARG DRIVER_VERSION=dev
ARG DRIVER_NAME=olake
# Copy the binary from the build stage
COPY --from=builder /olake /home/olake
# Sets the version of olake in ENV
ENV DRIVER_VERSION=${DRIVER_VERSION}
# Copy the pre-built JAR file from Maven
# First try to copy from the source location (works after Maven build)
COPY destination/iceberg/olake-iceberg-java-writer/target/olake-iceberg-java-writer-0.0.1-SNAPSHOT.jar /home/olake-iceberg-java-writer.jar
# Copy driver and destination spec files
COPY --from=builder /home/app/drivers/${DRIVER_NAME}/resources/spec.json /drivers/${DRIVER_NAME}/resources/spec.json
COPY --from=builder /home/app/destination/iceberg/resources/spec.json /destination/iceberg/resources/spec.json
COPY --from=builder /home/app/destination/parquet/resources/spec.json /destination/parquet/resources/spec.json
# Metadata labels
LABEL io.eggwhite.version=${DRIVER_VERSION}
LABEL io.eggwhite.name=olake/source-${DRIVER_NAME}
# Set working directory
WORKDIR /home
# Entrypoint
ENTRYPOINT ["./olake"]
# DB2 Specific Stage
FROM runtime-base-stage AS db2-stage
# Copy DB2 CLI Driver
COPY --from=builder /go/pkg/mod/github.com/ibmdb/clidriver /opt/clidriver
# Set DB2 CLI environment variables
ENV IBM_DB_HOME=/opt/clidriver
ENV PATH=$IBM_DB_HOME/bin:$PATH
ENV CGO_CFLAGS="-I$IBM_DB_HOME/include"
ENV CGO_LDFLAGS="-L$IBM_DB_HOME/lib -Wl,-rpath,$IBM_DB_HOME/lib"
ENV LD_LIBRARY_PATH=$IBM_DB_HOME/lib
# Default Stage (for all other drivers)
FROM runtime-base-stage AS driver-stage