Skip to content

Conversation

@danolivo
Copy link
Contributor

No description provided.

Replace the anti-pattern of setting environment variables via .bashrc
with proper Docker ENV directives. This ensures:

- Environment variables are available in all RUN commands
- No need to source .bashrc in build steps
- More reliable and Docker-native approach
- Cleaner and more maintainable Dockerfile

Variables moved to ENV:
- PATH: Includes PostgreSQL bin directory
- LD_LIBRARY_PATH: Includes PostgreSQL lib directory
- PG_CONFIG: Points to pg_config binary

This simplifies the Spock build step significantly.
Reformat the configure command from a single unreadable line with
eval and quoted options to a clean multi-line format.

Changes:
- Remove unnecessary eval (potential security concern)
- Remove shell variable with quoted options pattern
- Use direct ./configure with multi-line arguments
- Each option on its own line for easy review
- Improved maintainability for future option changes

This makes it much easier to:
- Review which features are enabled
- Add or remove configure options
- Understand the build configuration at a glance
Merge multiple RUN commands into single layers to reduce the number
of layers in the final Docker image. This optimization:

- Reduces image size by combining related operations
- Improves build efficiency
- Better utilizes Docker layer caching
- Follows Dockerfile best practices

Changes:
- PostgreSQL clone + chmod: 2 RUN → 1 RUN
- pgedge setup: 3 RUN → 1 RUN
- PostgreSQL compile: 2 RUN → 1 RUN
- Spock compile: 3 RUN → 1 RUN
- Added descriptive comments for each build stage
- Removed duplicate WORKDIR directive

Total reduction: ~6 fewer layers
Introduce a build argument to control the number of parallel make jobs
instead of using hardcoded values that differed between PostgreSQL
and Spock builds.

Changes:
- Add ARG MAKE_JOBS=4 (default value)
- Replace hardcoded -j4 (PostgreSQL) with -j${MAKE_JOBS}
- Replace hardcoded -j16 (Spock) with -j${MAKE_JOBS}
- Ensures consistent parallelism across all builds

Benefits:
- Can override at build time: --build-arg MAKE_JOBS=16
- Consistent behavior between PostgreSQL and Spock
- Easy to tune for different build environments
- Default of 4 is conservative and works on most systems

The previous inconsistency (j4 vs j16) is now eliminated.
Replace the two-step pattern of COPY + RUN chmod with the modern
COPY --chmod directive available in BuildKit.

Changes:
- COPY --chmod=755 instead of COPY + RUN sudo chmod +x
- Eliminates one RUN layer
- Removes unnecessary sudo usage

Benefits:
- One fewer layer in the final image
- Cleaner and more concise Dockerfile
- Uses modern Docker/BuildKit features
- Atomic operation (no window where files lack execute permission)

This is the recommended approach in modern Dockerfiles.
@danolivo danolivo merged commit 2e79949 into dockerfile-stable-llvm-fix Dec 26, 2025
4 of 5 checks passed
@danolivo danolivo deleted the claude/research-sugus-candy-BK32l branch December 26, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants