Skip to content

Add http proxy support to backend build in Docker #24

@fjlopez

Description

@fjlopez

Is your feature request related to a problem? Please describe.

Implement full support for building the backend behind a proxy in development and deployment environments that require it. The backend, built using Gradle inside Docker, should respect proxy settings defined via environment variables.

In proxy-restricted environments, the backend build fails due to missing or improperly injected proxy configuration. Specifically:

  • Gradle cannot download dependencies during the Docker build process.
  • Proxy variables (http_proxy, https_proxy, no_proxy) are not passed correctly into the container.
  • GRADLE_OPTS is ignored unless explicitly handled in the Dockerfile.
  • No-proxy settings are not respected for internal addresses.

This makes it impossible to build SITMUN 3 without modifications in environments where a proxy is required for outbound connections.

Describe the solution you'd like

The backend must be buildable behind a proxy, with the proxy configuration fully injectable via .env and Docker Compose.

*Implementation Proposal

  1. Define proxy settings in .env (already supported in other parts of the stack):
    HTTP_PROXY=xxxx:nnnn
    HTTPS_PROXY=yyyy:mmmm
    NO_PROXY=....
    GRADLE_OPTS="-Dhttp.proxyHost=xxxx -Dhttp.proxyPort=nnnn -Dhttps.proxyHost=yyyy -Dhttps.proxyPort=mmmm"
  2. Pass these variables to the Docker build context in docker-compose.yml:
     backend:
        build:
           args:
              - http_proxy=${HTTP_PROXY}
              - https_proxy=${HTTPS_PROXY}
              - no_proxy=${NO_PROXY}
              - GRADLE_OPTS=${GRADLE_OPTS}
        ....
        environment:
              - GRADLE_OPTS=${GRADLE_OPTS}
  3. Update the backend Dockerfile to use the variables correctly:
     FROM openjdk:11 AS build-backend-core
    
     ARG GRADLE_OPTS
     ENV GRADLE_OPTS=${GRADLE_OPTS}
     
     RUN echo "GRADLE_OPTS=${GRADLE_OPTS}"
     RUN --mount=type=cache,target=/root/.gradle ./gradlew --no-daemon -i stage
    ⚠️ ARG GRADLE_OPTS must be declared inside the same FROM stage where it’s used. Otherwise, the build will ignore the value.

Additional context
Adding proper proxy support improves development experience in secure or corporate environments and ensures CI/CD pipelines are compatible with constrained network configurations.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions