Skip to content

Commit

Permalink
OSMCha containers and helm templates (#305)
Browse files Browse the repository at this point in the history
* docker images for osmcha

* Add root user to install missing modules

Update values.yaml

* Refactoring osmcha

Update osmcha-deployments

Remove osmcha-api in chartpress

* Update Ruby version

Set ubuntu 20.04

Add missing libs

Add libv8-dev

Update ruby version

Fix web continaer

* Update ruby for taginfo

Add port names for osmcha

* Update osmcha deployment

Update osmcha deployment

Update services

* Update osmcha values

* Update osmcha wbe contianer and helm templates

* Update osmcha template

* Update config

* Update osmcha config

* Update osmcha service

* Update values

* Update overpass start script

* Update entrypoint overpass

* Update cmd for overpass

* Update overpas container

* Fix cli for overpass

* Update overpass api

* Update helm template for overpass

* Enable livenessProbe for overpass
  • Loading branch information
Rub21 authored Jan 5, 2024
1 parent bdee3bd commit 0ec6317
Show file tree
Hide file tree
Showing 21 changed files with 743 additions and 627 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ tiler-server/imposm/
overpass-api-db/
data/*/
!data/README.md
images/changeset-replication-job/config.yaml
images/changeset-replication-job/config.yaml
values_copy.yaml
1 change: 1 addition & 0 deletions chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ charts:
valuesPath: osmchaWeb.image
osmcha-db:
valuesPath: osmchaDb.image

50 changes: 43 additions & 7 deletions compose/osmcha.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,60 @@
version: '3'
version: "3.8"
services:
osmcha-db:
web:
platform: linux/amd64
image: developmentseed/osmseed-osmcha-web:v16
build:
context: ../images/osmcha-web
dockerfile: Dockerfile
env_file:
- ../envs/.env.osmcha
volumes:
- ../data/osmcha/staticfiles:/staticfiles
db:
platform: linux/amd64
image: osmseed-osmcha-db:v1
build:
context: ../images/osmcha-db
dockerfile: Dockerfile
ports:
- '5432:5432'
- "5432:5432"
volumes:
- ../data/osmcha-db-data:/var/lib/postgresql/data
env_file:
- ../envs/.env.osmcha
osmcha-web:
init:
platform: linux/amd64
image: osmseed-osmcha-web:v1
image: ghcr.io/willemarcel/osmcha-django:b1f4e6afc90e08707cadc4d74580632ca3b93dd2
command: >
/bin/bash -c "
set -x
python manage.py collectstatic
python manage.py migrate
mkdir -p /staticfiles/static
cp -r /app/staticfiles/* /staticfiles/static/
"
env_file:
- ../envs/.env.osmcha
volumes:
- ../data/osmcha/staticfiles:/staticfiles
api:
platform: linux/amd64
image: ghcr.io/willemarcel/osmcha-django:b1f4e6afc90e08707cadc4d74580632ca3b93dd2
build:
context: ../images/osmcha-web
context: ../images/osmcha-api
dockerfile: Dockerfile
command: >
/bin/bash -c "
set -x
python manage.py collectstatic
python manage.py migrate
mkdir -p /staticfiles/static
cp -r /app/staticfiles/* /staticfiles/static/
gunicorn --workers 4 --bind 0.0.0.0:5000 --log-file - --access-logfile - config.wsgi
"
ports:
- '8000:8000'
- "5000:5000"
env_file:
- ../envs/.env.osmcha
volumes:
- ../data/osmcha/staticfiles:/staticfiles
75 changes: 10 additions & 65 deletions images/osmcha-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,66 +1,11 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y -qq
RUN apt-get install -y curl python3 python3-dev \
python3-pip git libgeos-dev libyaml-dev \
libcurl4-gnutls-dev librtmp-dev python3-gdal \
locales nginx supervisor yarnpkg nodejs npm
RUN locale-gen en_US.UTF-8
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*

# Install yarn.
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -y
RUN apt-get remove -y yarnpkg cmdtest && apt-get install -y yarn && apt-get clean && rm -rf /var/lib/apt/lists/*

# Setup nginx
RUN rm /etc/nginx/sites-enabled/default
COPY django.conf /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/django.conf /etc/nginx/sites-enabled/django.conf
RUN echo "daemon off;" >> /etc/nginx/nginx.conf


# Setting locale is required by unicode-slugify (osmcha-django python requirement)
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en

FROM node:16-slim as builder
ENV DEBIAN_FRONTEND noninteractive
ENV BUILD_ENV=prod
ENV REACT_APP_PRODUCTION_API_URL=/api/v1
RUN apt-get update && apt-get install -y git
RUN mkdir /app
WORKDIR /app
ENV BACKEND_VERSION v4.19.0
RUN git clone https://github.com/willemarcel/osmcha-django .
RUN git checkout $BACKEND_VERSION
RUN git pull origin $BACKEND_VERSION
RUN pip3 install -r requirements/production.txt
RUN pip3 install -r requirements/local.txt

ADD . /app
ENV DJANGO_ROOT /app
ENV DJANGO_SETTINGS_MODULE config.settings.aws_production

# Replace social-auth-core by a modified version that provides OHM authentication
RUN pip3 install git+https://github.com/OpenHistoricalMap/social-core.git@master

# Upgrading requests to the latest version.
RUN pip3 install -U requests
RUN pip3 install certifi
RUN pip3 install django-extensions

# Clone and build the frontend
RUN git clone https://github.com/mapbox/osmcha-frontend.git /osmcha-frontend
RUN cd /osmcha-frontend && yarn install

RUN echo "alias python=python3" >> ~/.bashrc
RUN echo "alias pip=pip3" >> ~/.bashrc

EXPOSE 80

# Supervisor config
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY gunicorn.conf /etc/supervisor/conf.d/gunicorn.conf

COPY ./start.sh .
CMD ./start.sh
RUN git clone https://github.com/osmus/osmcha-frontend.git /app
RUN yarn install
COPY start.sh .
CMD [ "/app/start.sh" ]
14 changes: 0 additions & 14 deletions images/osmcha-web/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions images/osmcha-web/django.conf

This file was deleted.

6 changes: 0 additions & 6 deletions images/osmcha-web/gunicorn.conf

This file was deleted.

21 changes: 7 additions & 14 deletions images/osmcha-web/start.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#!/usr/bin/env bash
set -ex

# Build frontend
cd /osmcha-frontend
REACT_APP_VERSION=ohm REACT_APP_STACK=PRODUCTION PUBLIC_URL=$OSMCHA_URL npx react-scripts build
cp -R build/*.html /app/osmchadjango/frontend/templates/frontend/
cp -R build/* /app/osmchadjango/static/
cp -R build/static/* /app/osmchadjango/static/

# Start service
cd /app
python3 manage.py collectstatic --noinput
python3 manage.py migrate
supervisord -c /etc/supervisor/supervisord.conf
set -x
export BUILD_ENV=prod
export REACT_APP_PRODUCTION_API_URL=/api/v1
sed -i "s|https://osmcha.org|$OSMCHA_URL|g" package.json
yarn build:${BUILD_ENV}
find /app/build -type f -exec sed -i "s/www.openstreetmap.org/$OSMCHA_API_URL/g" {} +
cp -r /app/build/* /assets/
5 changes: 0 additions & 5 deletions images/osmcha-web/supervisord.conf

This file was deleted.

2 changes: 1 addition & 1 deletion images/overpass-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM wiktorn/overpass-api:0.7.56.8
FROM wiktorn/overpass-api:latest
COPY docker-entrypoint.sh /app/
RUN chmod a+rx /app/docker-entrypoint.sh
CMD ["/app/docker-entrypoint.sh"]
Loading

0 comments on commit 0ec6317

Please sign in to comment.