Skip to content

CGIMAP container #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
29f1164
Add cgmap container
Sep 1, 2023
e0f2388
Correct the misspelled name
Sep 1, 2023
a798afd
Add helm template for cgimap
Sep 1, 2023
d38f22c
Merge from develop
Rub21 Jun 14, 2024
9a90c8a
Update cgimap dockerfile
Rub21 Jun 20, 2024
60810bf
Merge branch 'develop' into cgmap
Rub21 Jun 20, 2024
951463d
Update tiler-imposm dockerfile
Rub21 Jun 20, 2024
36a3ae6
Update python
Rub21 Jun 20, 2024
057b8a2
Update cgimap container
Rub21 Jun 20, 2024
26c3a80
Update cgimap container
Rub21 Jun 20, 2024
c380960
Merge from develop
Rub21 Apr 9, 2025
905e88e
Update container for cgimap
Rub21 Apr 9, 2025
fe68c7e
Build cgimap image using multistage
Rub21 Apr 10, 2025
9630297
Update cgimap config
Rub21 Apr 11, 2025
89acb3b
Update release tags
Rub21 Apr 11, 2025
7d9409d
Add memcache server for cgimap
Rub21 Apr 14, 2025
a7c9418
Update cgimap start and github action
Rub21 Apr 14, 2025
1095b85
Add --daemon for cgimap
Rub21 Apr 14, 2025
8dac9a7
Set empty values for planetFiles.image
Rub21 Apr 14, 2025
2e179bd
Disable cgimap in chartpress
Rub21 Apr 14, 2025
42798ed
Use chartpress==2.3.0
Rub21 Apr 15, 2025
6549d9c
Add HorizontalPodAutoscaler for cgimap
Rub21 Apr 15, 2025
deadff6
Update web-api container
Rub21 Apr 16, 2025
347cec4
Fix apache config
Rub21 Apr 16, 2025
770ca83
Add PG password for tiler-db config as env var
Rub21 Apr 18, 2025
943eb10
Update cgimap dockerfile using code form original repo
Rub21 Apr 22, 2025
31aa902
Enable resources option for requests and limits - cgimap
Rub21 Apr 22, 2025
15e362a
Evaluate memoryUtilization for web container - autoscaling
Rub21 Apr 22, 2025
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
80 changes: 39 additions & 41 deletions .github/workflows/chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,42 @@ jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
- name: Install Chartpress and Python modules
run: |
pip install -v chartpress six yq
- name: Set env vars for publish charts
run: |
GIT_BRANCH_NAME=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
GIT_BRANCH_NAME=${GIT_BRANCH_NAME/\//_}
OSM_SEED_VERSION=$(yq -r .appVersion ./osm-seed/Chart.yaml)
SHORT_GITHUB_SHA=${GITHUB_SHA::7}
echo "GIT_BRANCH_NAME=$GIT_BRANCH_NAME" >> $GITHUB_ENV
echo "OSM_SEED_VERSION=$OSM_SEED_VERSION" >> $GITHUB_ENV
echo "SHORT_GITHUB_SHA=$SHORT_GITHUB_SHA" >> $GITHUB_ENV
- name: Run Chartpress
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: |
if [[ $GIT_BRANCH_NAME = "main" ]]
then
chartpress --push --publish-chart --tag ${OSM_SEED_VERSION}
elif [[ $GIT_BRANCH_NAME = "develop" ]]
then
chartpress --push --publish-chart --tag ${OSM_SEED_VERSION}-dev.h$SHORT_GITHUB_SHA
else
chartpress --push --publish-chart
fi

- uses: actions/checkout@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Setup git
run: git config --global user.email "[email protected]" && git config --global user.name "Github Action"
- name: Install Chartpress and some python modules
run: |
pip install -v chartpress==2.3.0 && pip install six && pip install yq
- name: Set env vars for publish charts
run: |
GIT_BRANCH_NAME=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
GIT_BRANCH_NAME=${GIT_BRANCH_NAME/\//_}
OSM_SEED_VERSION=$(yq -r .appVersion ./osm-seed/Chart.yaml)
SHORT_GITHUB_SHA=${GITHUB_SHA::7}
echo "GIT_BRANCH_NAME=$GIT_BRANCH_NAME" >> $GITHUB_ENV
echo "OSM_SEED_VERSION=$OSM_SEED_VERSION" >> $GITHUB_ENV
echo "SHORT_GITHUB_SHA=$SHORT_GITHUB_SHA" >> $GITHUB_ENV
- name: Run Chartpress
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: |
if [[ $GIT_BRANCH_NAME = "main" ]]
then
chartpress --push --publish-chart --tag ${OSM_SEED_VERSION}
elif [[ $GIT_BRANCH_NAME = "develop" ]]
then
chartpress --push --publish-chart --tag ${OSM_SEED_VERSION}-dev.h$SHORT_GITHUB_SHA
else
chartpress --push --publish-chart
fi

5 changes: 2 additions & 3 deletions chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ charts:
valuesPath: tilerServer.image
tasking-manager-api:
valuesPath: tmApi.image
# tiler-visor:
# valuesPath: tilerVisor.image
nominatim:
valuesPath: nominatimApi.image
overpass-api:
Expand All @@ -48,4 +46,5 @@ charts:
valuesPath: osmchaDb.image
planet-files:
valuesPath: planetFiles.image

# cgimap:
# valuesPath: cgimap.image
18 changes: 18 additions & 0 deletions compose/cgimap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
# #####################################################
# ## cgmap section
# #####################################################
cgimap:
image: osmseed-cgimap:v1
build:
context: ../images/cgimap
dockerfile: Dockerfile
ports:
- '80:80'
volumes:
- ../data/cgimap-data:/apps/data/
# command: >
# /bin/bash -c " ./start.sh"
env_file:
- ../envs/.env.db
41 changes: 41 additions & 0 deletions images/cgimap/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ruby:3.3.0 AS builder

ENV DEBIAN_FRONTEND=noninteractive
ENV workdir=/var/www
ENV CGIMAP_GITSHA=8ea707e10aeab5698e6859856111816d75354592
ENV cgimap=/tmp/openstreetmap-cgimap

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake git curl file \
libxml2-dev libpqxx-dev libfcgi-dev zlib1g-dev libbrotli-dev \
libboost-program-options-dev libfmt-dev libmemcached-dev libcrypto++-dev \
libargon2-dev libyajl-dev \
&& rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap \
&& cd $cgimap \
&& git checkout $CGIMAP_GITSHA \
&& mkdir build && cd build && cmake .. && cmake --build .


FROM ruby:3.3.0-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y --no-install-recommends curl gnupg && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
apt-get update && \
apt-get install -y --no-install-recommends \
libxml2 libpqxx-6.4 libfcgi zlib1g libbrotli1 \
libboost-program-options1.74.0 libfmt-dev libmemcached11 libcrypto++8 \
libargon2-1 libyajl2 libapache2-mod-fcgid postgresql-client \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

COPY --from=builder /tmp/openstreetmap-cgimap/build/openstreetmap-cgimap /usr/local/bin/openstreetmap-cgimap

COPY *.sh /
RUN chmod +x /*.sh && echo "/usr/local/lib" > /etc/ld.so.conf.d/local_libs.conf && ldconfig

CMD ["/start.sh"]
22 changes: 22 additions & 0 deletions images/cgimap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# openstreetmap-cgimap

This container is built using the configuration from Zerebubuth's OpenStreetMap CGImap GitHub repository, with minor modifications.


# Build and up

```sh
docker compose -f compose/cgimap.yml build
docker compose -f compose/cgimap.yml up
```

Note: Ensure that you are running PostgreSQL on your local machine. For example:


```sh
kubectl port-forward staging-db-0 5432:5432
```

Check results:

http://localhost/api/0.6/map?bbox=-77.09529161453248,-12.071898885565846,-77.077374458313,-12.066474684936727
17 changes: 17 additions & 0 deletions images/cgimap/liveness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
pgrep -f openstreetmap-cgimap > /dev/null
cgimap_status=$?

# Check PostgreSQL connection
PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 1;" > /dev/null 2>&1
postgres_status=$?

# Exit code logic
if [ $cgimap_status -eq 0 ] && [ $postgres_status -eq 0 ]; then
echo "cgimap and PostgreSQL are healthy"
exit 0
else
[ $cgimap_status -ne 0 ] && echo "cgimap not running" >&2
[ $postgres_status -ne 0 ] && echo "cannot connect to PostgreSQL" >&2
exit 1
fi
39 changes: 39 additions & 0 deletions images/cgimap/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

export PGPASSWORD=$POSTGRES_PASSWORD
export CGIMAP_HOST=$POSTGRES_HOST
export CGIMAP_DBNAME=$POSTGRES_DB
export CGIMAP_USERNAME=$POSTGRES_USER
export CGIMAP_PASSWORD=$POSTGRES_PASSWORD
export CGIMAP_OAUTH_HOST=$POSTGRES_HOST
export CGIMAP_UPDATE_HOST=$POSTGRES_HOST
# Export CGIMAP configuration
export CGIMAP_LOGFILE="/var/www/log/cgimap.log"
export CGIMAP_MEMCACHE=$MEMCACHE_SERVER
# Average number of bytes/s to allow each client
export CGIMAP_RATELIMIT="204800"
# Maximum debt in MB to allow each client before rate limiting
export CGIMAP_MAXDEBT="2048"
export CGIMAP_MAP_AREA="0.25"
export CGIMAP_MAP_NODES="100000"
export CGIMAP_MAX_WAY_NODES="2000"
export CGIMAP_MAX_RELATION_MEMBERS="32000"
# export CGIMAP_RATELIMIT_UPLOAD="true"
export CGIMAP_MODERATOR_RATELIMIT="1048576"
export CGIMAP_MODERATOR_MAXDEBT="2048"

if [[ "$WEBSITE_STATUS" == "database_readonly" || "$WEBSITE_STATUS" == "api_readonly" ]]; then
export CGIMAP_DISABLE_API_WRITE="true"
fi

if [[ "$WEBSITE_STATUS" == "database_offline" || "$WEBSITE_STATUS" == "api_offline" ]]; then
echo "Website is $WEBSITE_STATUS. No action required for cgimap service."
else
# PostgreSQL options to disable certain joins
export PGOPTIONS="-c enable_mergejoin=false -c enable_hashjoin=false"
# Display current PostgreSQL settings
psql -h $POSTGRES_HOST -U $POSTGRES_USER -c "SHOW enable_mergejoin;"
psql -h $POSTGRES_HOST -U $POSTGRES_USER -c "SHOW enable_hashjoin;"
# Start the cgimap service
/usr/local/bin/openstreetmap-cgimap --port=8000 --daemon --instances=10
fi
25 changes: 19 additions & 6 deletions images/tiler-imposm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,26 @@ RUN apt-get install -y \
software-properties-common && \
rm -rf /var/lib/apt/lists/*

# # Install python
RUN add-apt-repository ppa:deadsnakes/ppa && \
# Install Python 3.6
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt-get update && \
apt-get install -y build-essential python3.6 python3.6-dev python3-pip && \
rm -rf /var/lib/apt/lists/* && \
python3 -m pip install pip --upgrade && \
python3 -m pip install wheel
apt-get install -y gcc-8 g++-8 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100 && \
apt-get install -y build-essential wget libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev && \
wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz && \
tar xzf Python-3.6.15.tgz && \
cd Python-3.6.15 && \
./configure --enable-optimizations && \
make altinstall && \
cd .. && \
rm -rf Python-3.6.15 Python-3.6.15.tgz && \
apt-get install -y python3-pip && \
python3.6 -m pip install pip --upgrade && \
python3.6 -m pip install wheel && \
rm -rf /var/lib/apt/lists/*

# Install postgresql-client
RUN apt-get update && apt-get install -y postgresql-client && \
Expand Down
Loading
Loading