Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*/vendor
*.tar.gz
*.rpm
*.deb

# IDEA Project Files
.idea/
# Distribution files
dist

.phpunit.result.cache

# Git
.git
19 changes: 15 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
include:
- target: mapbender
tags: |
mapbender/mapbender:latest
mapbender/mapbender:${{ github.ref_name }}
- target: mapbender-puppeteer
tags: |
mapbender/mapbender-puppeteer:latest
mapbender/mapbender-puppeteer:${{ github.ref_name }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,12 +37,11 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
- name: Build and push Docker image (${{ matrix.target }})
uses: docker/build-push-action@v5
with:
context: .
target: ${{ matrix.target }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
mapbender/mapbender:latest
mapbender/mapbender:${{ github.ref_name }}
tags: ${{ matrix.tags }}
79 changes: 65 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
FROM php:8.3-apache AS base-container
# Stage: compile PHP extensions with dev dependencies
FROM php:8.4-apache AS php-ext-builder

ENV APACHE_DOCUMENT_ROOT=/var/mapbender/application/public
ENV API_UPLOAD_DIR=/var/mapbender/application/uploads/

RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
unzip \
openssl \
bzip2 \
sqlite3 \
curl \
libcurl4-gnutls-dev \
libgd-dev \
libicu-dev \
Expand All @@ -19,14 +12,37 @@ RUN apt-get update && apt-get install -y \
libsqlite3-dev \
libldap2-dev \
libonig-dev \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install pdo_pgsql
RUN docker-php-ext-configure gd --with-jpeg --with-freetype
RUN docker-php-ext-install curl gd intl mbstring zip bz2 xml pdo_sqlite ldap
RUN docker-php-ext-install opcache

# Stage: runtime base (no -dev packages, only runtime shared libs)
FROM php:8.4-apache AS base-container

ENV APACHE_DOCUMENT_ROOT=/var/mapbender/application/public
ENV API_UPLOAD_DIR=/var/mapbender/application/uploads/

# Copy compiled PHP extension binaries and ini configs from builder
COPY --from=php-ext-builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
COPY --from=php-ext-builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/

# Install only runtime libraries (no -dev / header packages)
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
libcurl3t64-gnutls \
libgd3 \
libicu76 \
libzip5 \
libonig5 \
libldap2 \
unzip \
openssl \
curl \
&& rm -rf /var/lib/apt/lists/*

RUN rm /etc/apache2/sites-enabled/*
COPY ./docker/mapbender_apache.conf /etc/apache2/sites-enabled/
COPY ./docker/php.ini /usr/local/etc/php/php.ini
Expand All @@ -42,21 +58,56 @@ EXPOSE 8080

COPY --chown=www-data:www-data . /var/mapbender/

FROM base-container as build-container
FROM base-container AS build-container

RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*

USER www-data
# required to create a complete mapbender application container image including all dependencies
RUN git config --global --add safe.directory /var/mapbender
RUN ./bootstrap


FROM base-container
FROM base-container AS mapbender

USER www-data

COPY --from=build-container --chown=www-data:www-data /var/mapbender /var/mapbender

CMD ["apache2-foreground"]

FROM base-container AS mapbender-puppeteer-build

RUN apt-get update && apt-get install -y --no-install-recommends \
npm \
nodejs \
&& rm -rf /var/lib/apt/lists/*

RUN npm install -g puppeteer
RUN chown www-data:www-data -R /usr/local/lib/node_modules/

USER www-data

RUN puppeteer browsers install

FROM base-container AS mapbender-puppeteer

RUN apt-get update && apt-get install -y --no-install-recommends \
nodejs \
libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgdk-pixbuf-xlib-2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget \
&& rm -rf /var/lib/apt/lists/*

COPY --from=mapbender-puppeteer-build /usr/local/lib/node_modules/ /usr/local/lib/node_modules/
COPY --from=mapbender-puppeteer-build --chown=www-data:www-data /var/www/.cache/puppeteer/ /var/www/.cache/puppeteer/
RUN ln -sf /usr/local/lib/node_modules/.bin/puppeteer /usr/local/bin/puppeteer
# Symlink so Node's standard module resolution finds puppeteer from any script under /var/mapbender
RUN mkdir -p /var/mapbender/node_modules && ln -sf /usr/local/lib/node_modules/puppeteer /var/mapbender/node_modules/puppeteer

ENV NODE_PATH=/usr/local/lib/node_modules

USER www-data

COPY --from=build-container --chown=www-data:www-data /var/mapbender /var/mapbender

CMD ["apache2-foreground"]