Skip to content

Commit 4d754b0

Browse files
committed
Align dev container Instant Client TZ data with Oracle server
CI applies the same workaround in #2734 to dodge ORA-01805 caused by drift between gvenzl/oracle-free:latest and the bundled Instant Client. Mirror it for the dev container without dragging the Docker CLI into the dev container itself. initializeCommand runs on the host, where Docker is already available. Pull the gvenzl image and copy timezlrg_*.dat out of it via an ephemeral container, dropping the file under .devcontainer/tzdata/ on the host. docker-compose bind-mounts that directory read-only at /opt/tzdata inside the dev container, and postCreateCommand exports ORA_TZFILE from there and persists it via /etc/profile.d so interactive shells and bundle exec runs pick it up. The TZ data ships in the image, so the copy step does not start Oracle or wait for the database. No docker-outside-of-docker feature, no /var/run/docker.sock bind mount, and no GPG-key fetching at build time.
1 parent 3b87a5b commit 4d754b0

5 files changed

Lines changed: 34 additions & 1 deletion

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
}
1717
},
18-
"initializeCommand": "docker pull gvenzl/oracle-free:latest",
18+
"initializeCommand": "bash .devcontainer/initializeCommand.sh",
1919
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
2020
"remoteEnv": {
2121
"DATABASE_NAME": "FREEPDB1",

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
dockerfile: Dockerfile
66
volumes:
77
- ..:/workspaces/oracle-enhanced:cached
8+
- ./tzdata:/opt/tzdata:ro
89
command: sleep infinity
910
network_mode: service:oracle
1011

.devcontainer/initializeCommand.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
IMAGE=gvenzl/oracle-free:latest
6+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
7+
OUT_DIR="$SCRIPT_DIR/tzdata"
8+
9+
docker pull "$IMAGE"
10+
11+
mkdir -p "$OUT_DIR"
12+
rm -f "$OUT_DIR"/timezlrg_*.dat "$OUT_DIR"/timezdif_*.dat
13+
14+
docker run --rm --entrypoint sh \
15+
-v "$OUT_DIR:/out" \
16+
"$IMAGE" \
17+
-c 'cp "$ORACLE_HOME"/oracore/zoneinfo/timezlrg_*.dat /out/ && chmod a+r /out/*.dat'
18+
19+
ls -1 "$OUT_DIR"

.devcontainer/postCreateCommand.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ set -e
55
gem update --system
66
bundle install
77

8+
# Match Instant Client TZ data to the Oracle server's to avoid ORA-01805.
9+
# The file is extracted from the gvenzl image into .devcontainer/tzdata/ by
10+
# initializeCommand.sh and bind-mounted read-only at /opt/tzdata.
11+
TZ_FILE=$(ls /opt/tzdata/timezlrg_*.dat 2>/dev/null | head -1)
12+
if [ -n "$TZ_FILE" ]; then
13+
echo "Using $TZ_FILE for Instant Client TZ data."
14+
export ORA_TZFILE="$TZ_FILE"
15+
echo "export ORA_TZFILE=$TZ_FILE" | sudo tee /etc/profile.d/ora-tzfile.sh > /dev/null
16+
else
17+
echo "Warning: no timezlrg_*.dat found under /opt/tzdata; skipping ORA_TZFILE setup." >&2
18+
fi
19+
820
echo "Waiting for Oracle to be ready..."
921
oracle_ready=false
1022
for i in $(seq 1 30); do

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Gemfile.lock
1414
ojdbc*.jar
1515
.byebug_history
1616
debug.log
17+
.devcontainer/tzdata/

0 commit comments

Comments
 (0)